[英]JQuery Ajax method called twice
I have this function in a jsp which calls a struts2
action. 我在一个调用
struts2
动作的jsp中具有此功能。 But it calls it twice. 但是它两次调用。 Why?
为什么?
JSP
$("#inputField").change(function()
{
var inputField= $("#inputField").val();
if(inputField !== '')
{
var url = 'myUrl';
$.getJSON(url, function(retVal)
{
$.each(retVal.retList, function(index, element)
{
console.log(element.name);
});
});
}
});
Struts2 Action
public String getJSON() throws Exception
{
System.out.println("Method Executed");
}
When this ajax
call returns, i get this 当这个
ajax
调用返回时,我得到了
Method Executed
Method Executed
How can i make this execute only once? 我怎样才能只执行一次?
您可能使用JSON插件,并且正在调用所有以“ get”开头的方法,以尝试对其进行序列化以进行输出。尝试重命名方法名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.