I want to make call to authenticate user and get back token in json file. I use Ext.data.JsonP but when I call it display Uncaught SyntaxError: Unexpected token : in browser.
I can’t use Ext.Ajax because it’s on another domain.
Here is code:
Ext.data.JsonP.request({
url : 'myurl',
success : function(result) {
alert('success');
},
failure : function(result) {
alert('failure');
},
callback : function(result) {
alert('callback');
}
});
And this is expected result:
{"token":"MTAwNTI7V00yWkdVMFlqZDtkMDExZWU4YmU4ZTdlM2RjYzNkYzU3OThhYWViYjk4YmMxMzY2NTY2"}
Can somebody tell me what’s causing Unexpected token : error?
Or other way how to get response.
Thanks
Your response is not valid JSONP? JSONP is just a JavaScript function with a (JSON) object being passed to it:
Ext.data.JsonP#requestwill automatically send acallbackparamater; so your server just needs to read that and use that parameter as the callback function.