Jquery在每次ajax调用时附加我的jsession ID [英] Appending my jsession ID at every ajax call by Jquery

查看:463
本文介绍了Jquery在每次ajax调用时附加我的jsession ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Weblogic上运行我的Web应用程序 应用服务器.我正在通过Jquery UI $ ajax和其他Jquery插件(即Jquery Datatables和JSTree)在我的应用程序中进行几次Ajax调用

I am running my web application on Weblogic application server.I am making several ajax calls in my application via Jquery UI $ajax and other Jquery Plugins (i.e. Jquery Datatables and JSTree)

现在我需要在所有这些调用中保持相同的会话.只应允许同一会话中的任何用户执行此操作.为此,我试图将JSESSIONID附加到每个ajax调用中.

Now i need to maintain same session in all these calls.Any user in the same session should only be allowed to do this.For this i am trying to append the JSESSIONID to every ajax call.

这种方法的问题是我不知道如何在我的javascript文件中获取此值.如果我在JSP中编写代码,我可以做到这一点,但是在javascript中我不知道这样做的方法

The problem with this approach is that i don't know how to get this value in my javascript file.If i write my code in JSP ,i can do that but in javascript i do not know of a way to do this.

请帮助我将其设置为Jquery,以便它随每个请求传递.

Please help me with a way to set it into Jquery so that it gets passed with every request.

谢谢

推荐答案

最好的解决方案是将其放在会话cookie中,该cookie将与AJAX请求一起传递,并且可以由服务器解释.无需更改任何JavaScript AJAX请求.

The best solution is to put it in a session cookie, which will be passed with the AJAX requests and can be interpreted by the server. No changes needed to any JavaScript AJAX requests.

下一个会更复杂.您可以编写一个jQuery.ajaxSend()函数来检查请求url(以确保它是您需要添加会话ID的URL),然后在发出AJAX请求之前将sessionID添加到数据对象中.

The next would be more complicated. You could write a jQuery.ajaxSend() function that checks the request url (to make sure it's one you need to add the session ID to) and add the sessionID to the data object before the AJAX request is made.

这篇关于Jquery在每次ajax调用时附加我的jsession ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆