I'm trying to load content from one of my sites in another:
<div id='include-from-outside'></div>
<script type='text/javascript'>
$('#include-from-outside').load('http://lujanventas.com/plugins/banner/index.php&callback=?');
</script>
But I'm getting this error:
XMLHttpRequest cannot load http://lujanventas.com/plugins/banner/index.php&callback=?. Origin http://lventas.com is not allowed by Access-Control-Allow-Origin.
How can I prevent it from happening?
There are two options:
1: make http://lujanventas.com return proper CORS headers -- http://enable-cors.org/
2: request the html using your server instead of with js in the browser -- http://www.daniweb.com/web-development/php/code/216729/php-proxy-solution-for-cross-domain-ajax-scripting
Use jquery ajax to query a php file that loads lujaventas content then the ajax callback will be lujaventas content.
The url you are using suggests the site supports JSONP (see http://en.wikipedia.org/wiki/JSONP). If so, you should be able to do it like this: