Chu Bao .Dev
Chu Bao .Dev

Reputation: 319

XMLHttpRequest cannot load and Sencha touch

everybody! I have a problem. When i use Ạjax or getStore, i see a error in console Chrome.

XMLHttpRequest cannot load . Origin is not allowed by Access-Control-Allow-Origin.

And, My response result is failed. I don't know this problem relate to this result. Help me, If you have a sulutions. :) Thanks.

When I use Ạjax or getStore, I see an error in Chrome's console.

XMLHttpRequest cannot load. Origin is not allowed by Access-Control-Allow-Origin.

And my response result is failed. I don't know this problem relates to the result.

Upvotes: 0

Views: 1482

Answers (3)

ThinkFloyd
ThinkFloyd

Reputation: 5021

You cannot call any webservice from your browser because of security reasons so either you have to use JSONP proxy on app side or you have to enable CORS on your server side. If you are planning to build this as app then you don't have to do this, all you have to do is change security setting of your browser when you are testing. More details here : How to use json proxy to access remote services during development

Upvotes: 1

sha
sha

Reputation: 17850

This appears to be cross domain Ajax call. Browser won't allow it by default. http://en.wikipedia.org/wiki/Same_origin_policy

You need to implement CORS http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

Upvotes: 0

Chu Bao .Dev
Chu Bao .Dev

Reputation: 319

This problem appears when i code like here:

Ext.Ajax.request({ 
url: 'http://api....api.php/national',
useDefaultXhrHeader: false,
success : function(response, opt) {     
Ext.Msg.alert('Success', response.responseText); 
},
failure : function(response, opt) {
Ext.Msg.alert('Failed', response.responseText); 
}   
});

Or:

var onlineStore = Ext.getStore('NationStore');
 onlineStore.load(); 

This is screen shot about error! Thanks! enter image description here

Upvotes: 0

Related Questions