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獲取錯誤消息作爲'允許起源'標題出現在所請求的資源。' –
您想要擊中的另一個網站可能不允許跨域請求 –