-1
A
回答
0
在Firefox和Chrome安裝插件CORS打API,IE只是處理得很好。 正如其他人所建議的那樣,你肯定是在locale(使用localhost)工作,所以CROSS來源請求是新瀏覽器通用的安全策略。 我不知道你的後臺,但如果它在阿賈克斯我會寫:
$.ajax({
url: "http://localhost:8079/students/add/",
type: "POST",
crossDomain: true,
data: JSON.stringify(somejson),
dataType: "json",
success: function (response) {
var resp = JSON.parse(response)
alert(resp.status);
},
error: function (xhr, status) {
alert("error");
}
});
如果你的後臺是在PHP中,你可以添加這些行:
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-Requested-With");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
的CORS或CROSS產地請求只是一個安全策略,當你在你的電腦上開發時,大多數情況下會觸發這個安全策略,請嘗試考慮是否存在惡意腳本並且你的瀏覽器沒有阻止跨域請求:
惡意代碼可能已經注入了你的網站代碼
相關問題
- 1. 跨域jQuery .AJAX問題
- 2. jQuery AJAX跨域問題
- 3. AJAX跨域問題
- 4. 在jQuery中的跨域問題ajax
- 5. JQuery的AJAX問題 - 也許跨域?
- 6. Jquery Ajax表單,跨域火狐問題
- 7. jquery跨域問題!
- 8. Jquery跨域問題
- 9. 跨域ajax iframe javascript問題
- 10. 跨域AJAX調用問題
- 11. coldfusion ajax jquery跨域
- 12. jQuery ajax WCF跨域
- 13. jquery跨域ajax 1.5.1
- 14. Ajax呼叫給我跨域錯誤
- 15. 使用.ajax(JQuery)跨域問題到我自己的域 - 簡單的PHP頁面
- 16. 跨域AJAX問心無愧的jQuery
- 17. 跨域問題
- 18. 跨域請求和jQuery/AJAX
- 19. Asp.net jquery ajax request.cookies跨域
- 20. jQuery ajax跨域請求
- 21. jQuery的Ajax跨域請求
- 22. 跨域的jQuery Ajax請求
- 23. 跨域Ajax調用jquery
- 24. Ajax跨域域庫
- 25. JQuery ajax跨域調用和權限問題
- 26. FullCalendar跨域問題
- 27. Javascript跨域問題
- 28. KendoUiMobile +跨域問題
- 29. RemoteObject - 跨域問題
- 30. iframes跨域問題
您需要在請求的資源上設置「訪問控制允許源」。 –
您是否對通過AJAX請求的域名有控制權? –