1

I'm not clear if my response to a JSONP call needs to have the callback reference in the response. For example, the following AJAX call:

$.ajax({
    type: 'GET',
    url: ajaxurl ,
    async: false,
    dataType: "jsonp",
    jsonpCallback: "do_teacher_survey_callback",
    data: {action: 'test'},
    success: function (result) {

    },
    error: function (request,error) {
    }
});

Does the response need to look like the following:

do_teacher_survey_callback({"field":"data"})

Or can I just return pure JSON like this:

 {"field":"data"}

I'm confused because I have used JSONP before to resolve cross-domain calls to servers that I had no control over the response and it worked fine.

SkyWalker
  • 28,384
  • 14
  • 74
  • 132
Lee Loftiss
  • 3,035
  • 7
  • 45
  • 73

0 Answers0