Ajax cross domain issues solved easily with PHP

Suggestions / Chats / News
Tools/Utilities Share
Web Development
Job Opportunties
Basically Everything Else.
doctorlai
Site Admin
Posts:44
Joined:Tue Jan 15, 2013 3:16 pm
Ajax cross domain issues solved easily with PHP

Post by doctorlai » Sun Jun 28, 2015 12:06 am

In PHP you set the following:

Code: Select all

  header("Access-Control-Allow-Origin: *");  


before

Code: Select all

header('Content-Type: application/json');


so that ajax code on different domains can still use the APIs.

Of course, there is other options such as JSONP (only GET is allowed) or directly modify the apache settings.

Post Reply