我正在尝试制作 Windows 8 应用程序,但我不断收到“javascript 运行时错误访问被拒绝”错误。错误发生在该页面上:
ajax.open("POST",'save-photo.php',false);
有什么想法以及我应该做什么吗?
最佳答案
由于跨域策略,您会看到此错误。查看有关 open method 的标准 MSDN 文档:
Security Warning: Cross-domain, cross-port, and mixed protocol requests are not allowed. The bstrUrl parameter may only specify files in the same domain, using the same port and protocol method, as that from which the page is served.
因为您的 Windows 应用商店应用程序正在服务 ms-wwa 协议(protocol) - 我想这就是您看到此错误的原因。
如果您需要在应用程序中显示外部网页,请查看此页面:How to link to external web pages (Windows Store apps using JavaScript and HTML) .
如果您需要从 Windows 应用商店应用程序上传文件,请查看此页面:Quickstart: Uploading a file (Windows Store apps using JavaScript and HTML)
关于javascript - "ajax.open"无法在 Windows 8 应用程序中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17129859/