-
28 Jun 2011 4:02 AM #1
Access-Control-Allow-Origin
Access-Control-Allow-Origin
XMLHttpRequest cannot load http://xyz. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
I get this Exception in my Chrome Browser.
The server I run is Apache (XAMPP).
How can I fix this? What can I do?
Thank you very much
My Source Code:
<script type="text/javascript">
new Ext.Application({
name: 'Hello World',
launch: function() {
Ext.Ajax.request({
url: 'http://xyz',
method: 'GET',
headers: {'Authorization': 'Basic GVU0IXZ6cFGzczE='},
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
}
});
</script>
-
28 Jun 2011 5:06 AM #2
Take a look as JSONP and ScriptTagProxy. Also read this wiki page: http://en.wikipedia.org/wiki/Same_origin_policy.
-
28 Jun 2011 5:46 AM #3
-
26 Sep 2011 9:34 AM #4
-
27 Sep 2011 12:24 AM #5
Hi Racon.
If you are trying to get data from a domain that is not your businness you have to use JSONP due to the same origin policy.
However, If you are developing an application on localhost that you will upload on the same domain you are trying to get data from, you don't need to use JSONP!
In this case you only need to open you application from file://.... intead of http://localhost/...
This will makes the trick and will allow you to get data from a different domain.
Hope this helps.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata


Reply With Quote