如何使一个指定使用jQuery的contentType JSONP POST请求? [英] How to make a jsonp POST request that specifies contentType with jQuery?
本文介绍了如何使一个指定使用jQuery的contentType JSONP POST请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要的内容类型应用/ JSON的一个JSONP POST请求。我可以得到POST请求到服务器是这样的:
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',
});
但只要我添加一行:的contentType:它开始发送它作为一个OPTIONS请求,而不是一个POST应用/ JSON的
我如何指定内容类型,仍然提交请求的帖子?
How can I specify the content type and still submit the request as a POST?
推荐答案
这是不可能使一个JSONP POST请求。
It is not possible to make a JSONP POST request.
JSONP通过创建一个<脚本>
,从不同的域执行JavaScript代码;它是不可能通过发送POST请求<脚本>
标记
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.
这篇关于如何使一个指定使用jQuery的contentType JSONP POST请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文