2
$.ajax({
type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
url : 'https://your_url.aspx', // the url where we want to POST
data : school, // our data object
dataType : 'json', // what type of data do we expect back from the server
encode : true
})
// using the done promise callback
.done(function(data) {
// log data to the console so we can see
console.log(data);
// here we will handle errors and validation messages
});
// stop the form from submitting the normal way and refreshing the page
event.preventDefault();
这是我的代码,以某种形式的数据上传到特定的网址张贴,但我收到以下错误:访问控制允许来源的错误,而在阿贾克斯
POST https://your_url.aspx 500 (Internal Server Error)
send @ jquery-3.2.1.min.js:4
ajax @ jquery-3.2.1.min.js:4
(anonymous) @ magic.js:20
dispatch @ jquery-3.2.1.min.js:3
q.handle @ jquery-3.2.1.min.js:3
index.html:1 XMLHttpRequest cannot load
https://your_url.aspx. No 'Access-Control-
Allow-Origin' header is present on the requested resource. Origin 'null' is
therefore not allowed access. The response had HTTP status code 500.
我环顾四周对于如何让访问控制允许来源和$就
beforeSend: function(request){
request.setHeaderRequest("Access-Control-Allow-Origin","*")
}
也计算器看到更多的答复后,后来我改变setHeaderRequest到addHeaderReuest使用,但即使如此,我没能看到响应从ser ver,虽然错误已被删除。控制台显示为空白。
任何帮助,将不胜感激。
写crossDomain:true也没有帮助。 –
不,在这里你cleraly获取错误消息作为'允许起源'标题出现在所请求的资源。' –
您想要击中的另一个网站可能不允许跨域请求 –