2

My AJAX call is:

$.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);
    }
});

I can see the result JSON in inspect elements in the browser, but I'm getting an error:

Error: jQuery111306513629604596645_1434294948077 was not called

Please help me. Thank you in advance

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Riyas PK
  • 21
  • 1

2 Answers2

0

I assume that 'jQuery111306513629604596645_1434294948077' may be the wrapper of you JSONP response - is it properly wraped within the method as it should be?

I can see your ajax method does not contain 'jsonpCallback' method. Here you have a similar issue: Callback function for JSONP with JQuery ajax

Community
  • 1
  • 1
Oskar Szura
  • 2,469
  • 5
  • 32
  • 42
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() {}
Riyas PK
  • 21
  • 1