为什么$ .ajaxSetup无法与$ .post一起使用 [英] Why does $.ajaxSetup not work with $.post
本文介绍了为什么$ .ajaxSetup无法与$ .post一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么此代码发布了sessionID参数
Why does this code post the sessionID parameter
$.post("ajax/p_getOnePosition.jsp", {
positionNo: positionNo,
sessionID: v_sessionID,
}, function(response2) {
但不是此代码
$.ajaxSetup({
sessionID: v_sessionID,
});
$.post("ajax/p_getOnePosition.jsp", {
positionNo: positionNo,
}, function(response2) {
推荐答案
使用 beforeSend
代替,如下所示.从此处 >
Use beforeSend
instead as follows. Code inspired from here
$.ajaxSetup({
beforeSend: function (jqXHR, settings) {
settings.data += "&sessionID="+v_sessionID;
}
});
$.post("ajax/p_getOnePosition.jsp", {
positionNo: positionNo,
}, function(response2) {
这篇关于为什么$ .ajaxSetup无法与$ .post一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文