简体   繁体   English

如何使用Webworks修复Javascript(jquery)中的“ Access-Control-Allow-Origin不允许访问null的原始null”错误?

[英]How do i fix “Origin null is not allowed by Access-Control-Allow-Origin” error in Javascript (jquery) with webworks?

I am trying to create a webworks app and trying to use jquery to post to a REST api - 我正在尝试创建一个Webworks应用程序,并试图使用jquery发布到REST api-

I get the following error 我收到以下错误

"Origin null is not allowed by Access-Control-Allow-Origin" “ Access-Control-Allow-Origin不允许原始null”

The javascript tries to post to a rest api using jquery javascript尝试使用jquery发布到rest api

I am getting the error when running it on chrome or firefox. 在chrome或firefox上运行时出现错误。 Some of the solutions I see on stackoverflow says that I need to run it on a webserver, but I would like to run it as a webworks app and therefore need to have it stand alone. 我在stackoverflow上看到的一些解决方案说,我需要在Web服务器上运行它,但是我想将其作为Webworks应用程序运行,因此需要使其独立运行。 Also, if I run this as hta (html application) it runs fine. 另外,如果我将其作为hta(html应用程序)运行,则可以正常运行。

The Same Origin Policy is in play here. 相同来源政策正在发挥作用。 If you can alter the api you are calling, you could use CORS on the newer browsers. 如果可以更改正在调用的api,则可以在较新的浏览器上使用CORS Or make the api support JSONP. 或者使api支持JSONP。 If you cannot change the service you are calling, you are sort of out of luck. 如果您无法更改正在呼叫的服务,那么您很不走运。

For allowing BlackBerry 10 to call an URL from an WebWorks app you need to add this line inside your config.xml : <access uri="*" subdomains="true" /> 要允许BlackBerry 10从WebWorks应用程序调用URL,您需要在config.xml中添加以下行: <access uri="*" subdomains="true" />

Hope this will solve your issue 希望这能解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Access-Control-Allow-Origin不允许使用Origin null(同步,无jQuery) - Origin null is not allowed by Access-Control-Allow-Origin (Synchronous, no jQuery) 使用JQuery更新OData时出现错误“ Access-Control-Allow-Origin不允许Origin null” - Error “Origin null is not allowed by Access-Control-Allow-Origin” when using JQuery to update OData jQuery使用WCF。 错误:XMLHttpRequest无法加载Access-Control-Allow-Origin不允许使用Origin null - Jquery to consume WCF. error: XMLHttpRequest cannot load Origin null is not allowed by Access-Control-Allow-Origin Access-Control-Allow-Origin不允许使用Chrome Origin null - Chrome Origin null is not allowed by Access-Control-Allow-Origin Access-Control-Allow-Origin不允许使用null - Origin null is not allowed by Access-Control-Allow-Origin Access-Control-Allow-Origin 不允许来源 null - Origin null is not allowed by Access-Control-Allow-Origin 无法与jsonp配合使用的Access-Control-Allow-Origin不允许使用Origin null - Origin null is not allowed by Access-Control-Allow-Origin not working with jsonp Access-Control-Allow-Origin不允许使用原点null - Origin null is not allowed by Access-Control-Allow-Origin Jquery (jfeed) - Access-Control-Allow-Origin 不允许来源 xxxxx - Jquery (jfeed) - Origin xxxxx is not allowed by Access-Control-Allow-Origin Access-Control-Allow-Origin 不允许 Origin - Origin is not allowed by Access-Control-Allow-Origin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM