Javascript 将变量传递给ajax回调函数

Javascript 将变量传递给ajax回调函数,javascript,jquery,ajax,Javascript,Jquery,Ajax,我是AJAX新手,所以我使用“Jquery表单” 我需要通过成功回调传递条目和路径变量 var optionsUpdate = { data: { entry: entry, path: path }, success: updateLoad, }; function updateLoad(data) { var wrapper = '.recent-order-item'+data.entry; $(wrapper).load(data.path); }

我是AJAX新手,所以我使用“Jquery表单”

我需要通过
成功回调
传递
条目
路径
变量

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; 
});  

谢谢我已经将我问题中的代码修改为您显示的代码。我假设我可以使用“data.entry”来调用,但我无法让它工作。有什么想法吗?是的,上面说options update.data是undefined@user2889310 .. 我看到您已从选项更新对象中删除数据对象。。。还原…我已再次更新代码。我已尝试添加具有上述内容的数据对象,以及data.entry等,但它显示为“entry”未定义。将其设置为
-->
数据:{entry:'',path:'}