PDA

View Full Version : "Uncaught SyntaxError: Unexpected token :" when using JSONP and scripttag



epiphanydigital
27 Jun 2011, 10:09 AM
Does anyone have any idea why this wouldn't work? I get the error when trying to load the json from my server.

"Uncaught SyntaxError: Unexpected token :" when using JSONP and scripttag



Ext.regModel('MenuItem', {
fields: [
{name: 'id', type: 'int'},
{name: 'title', type: 'string'}
//{name: 'body', type: 'string'}
]
});

MyDS.MenuStore = new Ext.data.Store({
model: 'MenuItem',
proxy: {
//type: 'ajax',
type: 'scripttag',
url: 'http://1ldev251.iqsolutions.com/myds2-rpc/testing.json', // DOES NOT WORK, EXACTLY THE SAME CONTENT AS THE BELOW URL:
//url: 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22hello%22%20limit%2010', // WORKS!
reader: new Ext.data.JsonReader({
root: 'query.results.photo'
})
}
});

epiphanydigital
28 Jun 2011, 6:19 AM
So the answer to this question is found here on another thread I was on, hopefully this helps someone else as well. Thanks bclinton for all your help!

http://www.sencha.com/forum/showthread.php?138533-quot-Uncaught-SyntaxError-Unexpected-token-quot-when-using-JSONP-and-scripttag

stevanicus
19 May 2012, 1:33 AM
thank you was missing this




$callback = $_REQUEST['callback'];if($callback){ header('Content-Type: text/javascript, charset=UTF-8'); echo $callback . '(' . json_encode($response) . ');';}else{ header('Content-Type: application/x-json, charset=UTF-8'); echo json_encode($response);}