2015-06-14 52 views
2

我的AJAX调用是:得到“错误:jQuery111306513629604596645_1434294948077未被调用”错误时,跨域AJAX调用?

$.ajax({ 
    method: "GET", 
    contentType: "application/json; charset=utf-8", 
    url: "http://localhost:8080/viewalldoctorprofile", 
    dataType: 'jsonp', 
    crossDomain: true, 
    success : function(json){ 
     alert("24254"); 
    }, 
    error: function (xhr, ajaxOptions, thrownError) { 
     alert(xhr.status); 
     alert(thrownError); 
    } 
}); 

我可以看到结果JSON在检查元素在浏览器中,但我发现了一个错误:

Error: jQuery111306513629604596645_1434294948077 was not called

请帮助我。预先感谢您

回答

0

我假设'jQuery111306513629604596645_1434294948077'可能是你的JSONP响应的包装 - 它是否正确地包装在方法,因为它应该是?

我可以看到你的ajax方法不包含'jsonpCallback'方法。这里有类似的问题:Callback function for JSONP with JQuery ajax

0
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 
    HttpServletResponse response = (HttpServletResponse) res; 
    response.setHeader("Access-Control-Allow-Origin", "*"); 
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 
    response.setHeader("Access-Control-Max-Age", "3600"); 
    response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); 
    chain.doFilter(req, res); 
} 

public void init(FilterConfig filterConfig) {} 

public void destroy() {}