HTML5 cocos2d JS Access-control-allow-origin

Source: Internet
Author: User

1.No ' Access-control-allow-origin ' header is present on the requested


Recently in the channel of HTML5, encountered cross-domain problem, using JS Ajax post or Get method, only to the target URL slightly different, there will be cross-domain issues, the browser will be the security of their own initiative to intercept.

This problem is in fact not the client can solve, preferably the target URL of the server code is you can control. The most convenient solution is to add code to the server-side page you are visiting. For example, your address today is http://a.company.com to visit http://b.company.com. You should add code that agrees to cross-domain access in http://b.company.com.

PHP code such as the following:

Header (' access-control-allow-origin: * ');    Header ("Access-control-allow-credentials:true");    Header (' Access-control-allow-methods:get, PUT, POST, DELETE, OPTIONS ');    Header (' access-control-max-age:1000 ');    Header (' Access-control-allow-headers:content-type, Content-range, content-disposition, Content-description ');

2. Jump or there will be a problem


For example, you are in the http://b.company.com of the server code and jump to http://c.other.com, and http://c.other.com not under your control, then you can use this little tricks. Return URL to JS, let JS through location.href = "http://c.other.com" to jump.

http://www.waitingfy.com/archives/1737

HTML5 cocos2d JS Access-control-allow-origin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.