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, as long as the target URL slightly different, there will be cross-domain problems, the browser will be automatically blocked due to security issues.

This problem is not the client can be solved, preferably the target URL of the server code is you can control, the most convenient solution is the server-side page you access to add code. For example, your current address is http://a.company.com. To access http://b.company.com, you should include code that allows cross-domain access in http://b.company.com.

The PHP code is as follows:

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 in the Http://b.company.com server code and jump to http://c.other.com, and http://c.other.com not under your control, then you can use such a small trick, return URL to JS, let JS through Location.href = "http://c.other.com" to jump.

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

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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.