Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  78] [ 4]  / answers: 1 / hits: 41611  / 14 Years ago, tue, october 5, 2010, 12:00:00

I need to make a jsonp POST request with the content type 'application/json'. I can get the POST request to the server like this:



      jQuery.ajax({
type: 'POST',
url: url,
data: data,
success: success,
error: error,
async: true,
complete: complete,
timeout: TIMEOUT,
scriptCharset: 'UTF-8',
dataType: 'jsonp',
jsonp: '_jsonp',
});


But as soon as I add the line:contentType: application/json it starts sending it as an OPTIONS request rather than a POST.



How can I specify the content type and still submit the request as a POST?


More From » jquery

 Answers
8

It is not possible to make a JSONP POST request.



JSONP works by creating a <script> tag that executes Javascript from a different domain; it is not possible to send a POST request using a <script> tag.


[#95420] Friday, October 1, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hugo

Total Points: 21
Total Questions: 120
Total Answers: 107

Location: Belarus
Member since Tue, Jul 20, 2021
3 Years ago
;