我有一个简单的JS函数,可以从浏览器中的URL中检索一些数据。在JSP中调用JS函数。从JSP中的标记内调用JS函数。
JS功能:
function parseURL(){
var info = "some value", // This is retrieved from the browser URL which is my.JSP
$.ajax({
method: post,
url: my.jsp // This is the same URL (browser URL) from which I am getting information, so I just send back to it
data: { information: info} )}
.done({
alert("Success");
})
});
}
当我尝试在JSP中的scriplet中检索值时,它返回null。我究竟做错了什么?任何帮助将不胜感激。谢谢。
答案 0 :(得分:0)
我建议您按照这些步骤找到适合您案例的方法!
首先在你的功能中
function parseURL(){
var info = "some value", // This is retrieved from the browser URL which is my.JSP
$.ajax({
method: post,
url: anotherPage.jsp // This is the same URL (browser URL) from which I am getting information, so I just send back to it
data: { information: info} )}
.done({
$("div or section where you want to inject the result").html(data);
})
});
}
并在anotherPage.jsp中尝试使用以下内容:
// jsp标题和东西以及想要返回的数据,例如scriplet或表达式,只是将由前面的函数注入的数据 如果你可以发布my.jsp和另一个可能有用的anotherPage.jsp