使用ajax異步請求

使用ajax異步請求的格式如下:

                //先序列化所有參數,再通過ajax提交數據
                    var params = $.param({
                        'buycarid':othis.buycarid,
                        'actprice': $('#actprice').val(),
                        'numbers': $('#numbers').val(),
                    }, true);

                    $.ajax({
                        url: '/updatebuycar.action',//請求路徑
                        type: 'post',
                        data: params,//傳輸的數據
                        dataType: 'json',
                        success: function (data) {//返回值的處理
                            if (data === "0") {
                                layer.msg("更新成功");
                                window.location.href = '/admin/buycars/showbuycar?customerid='+othis.customerid;
                            }else {
                                layer.msg("更新失敗");
                            }
                        }
                    });


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章