Html 跨域不工作有错误请求必须是POST
我在跨域使用JSON我的代码是Html 跨域不工作有错误请求必须是POST,html,asp.net,json,cross-domain,Html,Asp.net,Json,Cross Domain,我在跨域使用JSON我的代码是 var sourceCode = window.cseditor.getValue() || document.getElementById("sourcecode").value; alert(sourceCode); setStatus("Compiling..."); $.ajax({ type: "POST", url: "http://jsil.org/try/compile.aspx", co
var sourceCode = window.cseditor.getValue() || document.getElementById("sourcecode").value;
alert(sourceCode);
setStatus("Compiling...");
$.ajax({
type: "POST",
url: "http://jsil.org/try/compile.aspx",
contentType: "text/plain; charset=UTF-8",
cache:false,
dataType: "jsonp",
data: sourceCode,
success: compileComplete,
error: function (xhr, status, moreStatus) {
compileComplete(false, status + ": " + moreStatus);
},
});
上述代码的ajax响应是:
“网络错误:400错误请求-20%20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20%20 20 20 20 20 20 20 20 20%20 20%20 20 20 20 20%20 20 20 20%20 20 20 20%20 20 20 20 20 20 20%20 20 20%20%20 20 20 20%20 20 20 20%20 20 20%20 20 20 20 20%20 20 20 20 20%20 20 20 20 20%20 20 20%20 20 20 20 20 20%20 20 20 20 20 20%20 20 20 20%20 20 20%20 20 20 20%20 20 20 20 20%20 20 20 20 20%20 20 20 20 20 20%20 20 20 20 20 20 20 20 20%20 20 20 20 20%20 20 20%20 20 20 20 20 20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20canvas%20=%20document.createElement(%22canvas%22);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20ctx%20=%20canvas.getContext(%222d%22)20 20%20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20body.appendChild(画布);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20重新绘制(ctx);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2025)20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20静态%20%20%20%20%20%20%20%20%{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20x%20+=%202;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.clearRect(0、%200、%20300、%20300)20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20&您正在使用JSONP。JSONP只支持GET请求
将服务器配置为返回纯JSON(具有适当的内容类型和访问控制头),并省略
数据类型
参数(或将其设置为'JSON'
).我需要使用POST,我使用html页面,那么如何添加头部?@IrshadKiru-你已经说过了。照我说的做。如果你想使用POST,不要使用JSONP。你可以参考此页面。。。