Skip to content Skip to sidebar Skip to footer

Javascript API Is Working Fine On The Main Site, But Fails To Work On An External Server

This code can be used in conjuction with jQuery to embed a button on a page letting users share a link to my site.
); ?>

or

   <?php header('Access-Control-Allow-Origin: *'); ?>

(the wildcard is going to allow any domain to send requests to your host. I recommend replacing the asterisk with a specific domain that you will be running scripts on)

Also you need to send Origin header from ajax to the server

Origin: http://example.com/ajax.html

XMLHttpRequest cannot load filename.

  • is because you didn't specify full url in you ajax request. But it works with your main server because you run php in the same domain itself.

Post a Comment for "Javascript API Is Working Fine On The Main Site, But Fails To Work On An External Server"