ajax 调用另一个 url 重置 JsessionId 因此无法继续处理其他链接
我通过jquery.ajax
call()调用restAPI,一旦完成,我就无法使用其他ajax调用,因此我被spring security
抛弃了。我注意到完成restAPI调用后JsessionID
发生了变化(我使用httpFox插件来火狐)。因此,在其余 API 调用之后,我将通过 Spring Security 重定向到登录页面。我注意到我不再是授权用户了。我想如果我可以保留最初的“jsessionID”并通过浏览器使用它那就没问题了。谁能给我一些指导我该怎么做?提前致谢。
这是我的其余 api 的代码
jQuery.ajax({
type: "POST",
//contentType: "application/json; charset=utf-8",
url: restUrl,
data: "{}",
dataType: "json",
success: function(msg) {
// load grids
try{
loadBaseGrid(); //this is a jqgrid
//will trigger once ajax call is success. but this
//will not complete successfully. becouse of the jsession ID change
}catch(e){
trace('Error in loadBaseGrid -'+e);
}
},
beforeSend : function(req) {
//req.setRequestHeader("Access-Control-Allow-Origin", "*");
//req.setRequestHeader('Authorization', token);
},
error:function (xhr, ajaxOptions, thrownError){
var res = xhr.responseText;
try{
//var err = JSON.parseWithDate(res);
trace(err);
}catch(e){
trace('Error ->'+e);
}
}
});
I am calling to a restAPI through jquery.ajax
call() once it completed i cannot use my other ajax calls hence i am thrown away from the spring security
. i noticed the JsessionID
change upon complete the restAPI call (i used httpFox plugging for fire fox). so what ever i am doing after the rest API call i will redirect to the Login page by spring security
. i noticed that i am not authorized user anymore. i thought if i can keep the initial 'jsessionID' and use it through my browser it will be fine. can anyone please give me some guidance how i can do it? Thanks in advance.
this is my code to the rest api
jQuery.ajax({
type: "POST",
//contentType: "application/json; charset=utf-8",
url: restUrl,
data: "{}",
dataType: "json",
success: function(msg) {
// load grids
try{
loadBaseGrid(); //this is a jqgrid
//will trigger once ajax call is success. but this
//will not complete successfully. becouse of the jsession ID change
}catch(e){
trace('Error in loadBaseGrid -'+e);
}
},
beforeSend : function(req) {
//req.setRequestHeader("Access-Control-Allow-Origin", "*");
//req.setRequestHeader('Authorization', token);
},
error:function (xhr, ajaxOptions, thrownError){
var res = xhr.responseText;
try{
//var err = JSON.parseWithDate(res);
trace(err);
}catch(e){
trace('Error ->'+e);
}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试附加 JSESSIONID=?在 jquery 中的其余 url 上
所以:
Try appending the JSESSIONID=? on the rest url in jquery
So: