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
  • 26,885
  • 10
  • 68
  • 127
Lee Loftiss
  • 2,965
  • 7
  • 44
  • 67

0 Answers0