【发布时间】:2011-04-21 01:56:14
【问题描述】:
我需要创建一个内容类型为“application/json”的 jsonp POST 请求。我可以像这样向服务器发送 POST 请求:
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: "application/json",它就会开始将其作为 OPTIONS 请求而不是 POST 发送。
如何在指定内容类型的同时仍将请求作为 POST 提交?
【问题讨论】:
-
该 URL 在您的域中吗?它返回什么格式?
标签: javascript jquery ajax http jsonp