私の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を確認できますが、エラーが発生しています:
エラー:jQuery111306513629604596645_1434294948077が呼び出されませんでした
私を助けてください。前もって感謝します
回答:
回答№1は0「jQuery111306513629604596645_1434294948077」がJSONP応答のラッパーになる可能性があると想定しています-メソッド内に適切にラップされている必要がありますか?
あなたのajaxメソッドには「jsonpCallback」メソッドが含まれていないことがわかります。同様の問題があります: JQuery ajaxを使用したJSONPのコールバック関数
回答№2の場合は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() {}