javascript - "ajax.open"无法在 Windows 8 应用程序中运行

标签 javascript ajax windows-8

我正在尝试制作 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/

相关文章:

javascript - 为什么堆栈跟踪在 .ts 文件中的一行中显示 3 个调用

javascript - 如何在选中复选框时使用 javascript 选择一行单选按钮

php - 如何在php类中使用ajax

php - 在页面加载时显示进度轮

javascript - WinRT - StreamSocket - 通过 LoadAsync 读取数据时关闭连接

javascript - 移动图像不能超出窗口 DOM

javascript - 日期范围选择器输入字段不是 24 小时格式

php - Ajax序列化;无法在 PHP 中使用 'read' 变量

c# - 当目标应用程序以管理员身份运行时,ShowWindow 功能不起作用

python - 为什么在将 Unicode 写入 CMD 时会出现 IOErrors? (代码页 65001)