【发布时间】:2013-02-07 22:25:31
【问题描述】:
我需要通过 ajax(不是 json)向另一个域提交表单,但不断收到错误
XMLHttpRequest cannot load http://some.other.domain/. Origin http://localhost:8081 is not allowed by Access-Control-Allow-Origin.
有没有办法“解决”这个问题?
$.ajax({
type: "POST",
dataType: "text/html",
data: $("#surveyForm").serialize(),
crossDomain: true,
url: "http://some.other.domain",
processData: false,
error: function (jqXHR, textStatus, errorThrown) {
},
success: function (response) {
}
});
【问题讨论】:
-
您拥有其他域吗?如果是这样,您可以将 CORS 标头添加到响应中:html5rocks.com/en/tutorials/cors
-
很遗憾,我不拥有另一个域。