Reputation: 7
I'm just trying to get login page for my app with this code:
<script type="text/javascript">
$(document).ready(function() {
$(".loa").load("http://www.agroagro.com/login.php");
});
</script>
I get this error:
XMLHttpRequest cannot load http://www.agroagro.com/login.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://agroagro.com' is therefore not allowed access.
The problem is when I have only .load(login.php) everything works fine but when I type .load(agroagro.com/login.php) I get error from above, so becouse i want to use phonegap to build native app i need to have full url address?
Any idea how to solve this?
Also one more question - Is better way like I do load .php file via JQ or is better to make a AJAX call to php file ?
For me its easier to make a load .php file becouse I have code there where I'm not using ajax.
What about performance - load .php or make ajax call ?
Upvotes: 0
Views: 257
Reputation: 671
The Browsers do not allow us to make call to other domains unless or otherwise we have had the allow request from where we are requestion or for all other domains
header('Access-Control-Allow-Origin: *');
Use the above line in the http://www.agroagro.com/login.php
page
Hope it works
Upvotes: 1