JQuery.ajax () with jsonp not calling success callback function

I have a iframe facebook application that makes a cross domain request on my server and requests data in JSONP format. This is the code of my client side:

jQuery.ajax({ url: '***', type: 'post', data: { method: 'set_user_prizes' }, dataType: 'jsonp', jsonp: false, jsonpCallbackString: 'callback123', success: function(data, textStatus, jqXHR){ console.log('success_function'); console.log(data); } }); 

The problem is that my callback method is not called, and I'm not sure why. Using Firebug, I see my server response:

 callback123({"success":true,"associated_prizes":[{"prizes_id":"6"},{"prizes_id":"1"}]}) 
+6
source share
2 answers

Remove the word String from the callback key, as shown in the following conversion. The value must remain a string.

Edit:

 jsonpCallbackString: 'callback123', 

to

 jsonpCallback: 'callback123', 
+6
source

Correct answer

 jsonpCallback: 'callback123' 
+4
source

Source: https://habr.com/ru/post/897171/


All Articles