問題描述
我正在進行同步 ajax 調用(ajax 設置 async: false ).這很好用.
I am making a synchronous ajax call ( ajax settings async: false ). This works well.
現在我正在嘗試在 phantomJS 中為此編寫一個自動化測試,但出現此錯誤
Now I'm trying to write an automated test for this in phantomJS and I'm getting this error
NETWORK_ERR: XMLHttpRequest Exception 101
我檢查了我的服務日志,似乎服務沒有收到任何請求.
I checked my service logs and it seems like service is not getting any request.
推薦答案
嘗試在運行腳本時使用命令行選項 --web-security=no
禁用網絡安全.(phantomjs --web-security=no yourscript.js
)
Try disabling the web security by using the command-line option --web-security=no
when running your script. (phantomjs --web-security=no yourscript.js
)
來自 PhantomJS 參考 (http://phantomjs.org/api/command-line.html):
From the PhantomJS reference (http://phantomjs.org/api/command-line.html):
"--web-security=[true|false]
啟用網絡安全并禁止跨域 XHR(默認為 true).也接受:[yes|no]代碼>
"--web-security=[true|false]
enables web security and forbids cross-domain XHR (default is true). Also accepted: [yes|no]
這篇關于Phantom JS 同步 AJAX 請求:NETWORK_ERR: XMLHttpRequest Exception 101的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!