2015-06-14 36 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() {}