我对 AJAX 相当陌生,所以正在使用“Jquery Form”。
我需要通过成功回调
传递entry
和path
变量。
var optionsUpdate = {
data: { entry: entry, path: path },
success: updateLoad,
};
function updateLoad(data) {
var wrapper = '.recent-order-item'+data.entry;
$(wrapper).load(data.path);
}
$('.status_update').submit(function() {
optionsUpdate.data.entry = $(this).attr('id');
optionsUpdate.data.path = '/orders/embed-order-item/'+optionsUpdate.data.entry;
$(this).ajaxSubmit(optionsUpdate);
return false;
});
谁能解释一下这是如何完成的?
最佳答案
您需要在提交时更新对象值 -
$('.status_update').submit(function() {
optionsUpdate.data.entry = $(this).attr('id');
optionsUpdate.data.path = '/orders/embed-order-item/'+optionsUpdate.data.entry;
$(this).ajaxSubmit(optionsUpdate);
return false;
});
关于javascript - 将变量传递给 ajax 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22784794/