View Full Version : Error while trying to get json from url
I get " xhr.getAllResponseHeaders() is null " error when I execute following code:
Ext.Ajax.request({
url: 'http://demo.webfactory.mk',
params: {action : 'retrieve'},
success: function(response, opts) {
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});I don't know what's the problem. Could somebody help me?
Thanks in advance,
Ilija
mrsunshine
6 Dec 2010, 4:56 AM
did you chec if you get a valid json result when you request the same url in the webbrowser?
you can validate you json response with http://www.jsonlint.com/
http://www.google.com.au/url?sa=t&source=web&cd=1&sqi=2&ved=0CBgQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame_origin_policy&ei=MOH8TKPKAYymvQOzrbXMCg&usg=AFQjCNHVFZYpkC1JSDNgda021fYJ8pRuDQ
did you chec if you get a valid json result when you request the same url in the webbrowser?
you can validate you json response with http://www.jsonlint.com/
I check the json response and it is valid.
mrsunshine
6 Dec 2010, 6:06 AM
did you do a cross domain request like evant mentioned?
whats the app url
whats the url from you json service?
My url is http://demo.webfactory.mk/?action=retrieve.
I try to call this web service from local machine.
Thanks in advance,
Ilija
mrsunshine
6 Dec 2010, 8:39 AM
What you want todo is a crossdomain ajax request, thas by default forbidden, thats what evant mentioned. if you want todo a crossdomain ajax request you have to use a
Ext.data.ScriptTagProxy http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.ScriptTagProxy
stefan_k
6 Dec 2010, 8:53 AM
Additionally, you may take a look at the documentation for Ext.util.JSONP (http://dev.sencha.com/deploy/touch/docs/?class=Ext.util.JSONP)
Thanks, it solved the problem.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.