jeremym
23 Feb 2012, 1:19 PM
I'm trying to use a jsonp proxy (since the ajax proxy doesn't allow for cross-domain calls). When I switched I discovered I was getting back the data I expected, but with an "Invalid Label" error... After poking around google a bit, it looks like the issue is that jsonp response needs to be wrapped in a function... so instead of { "key1" : " value1" , "key2": "value2" } its supposed to be callBackFunct({ "key1" : " value1" , "key2": "value2" }); ... So I took some known output from the server and saved it as a .json file on my localhost... after confirming that it loaded successfully with an ajax proxy, I switched to a jsonp proxy type and wrapped the json in "myCallback(<jsonhere>);" ... When I try to access this via the jsonp proxy I get an error "myCallback is not defined". I'm using the a file for now for testing, but will be able to control how the server wraps the data once I've got the right client side solution... Reading http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.JsonP (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.proxy.JsonP) makes it sound like the client doesn't have to do anything and that the proxy will handle it, but clearly I'm missing some element.
My store code:
proxy: {
type: 'jsonp',
url: 'data/smalltest.json',
headers: { Authorization : 'Basic YWRtTEMPNOTREALaW4=' },
callbackKey: 'myCallback',
reader: {
type: 'json',
root: 'appMetrics'
}
}
Small snippet of the json:
myCallback({
"query_info": {
"granularity": "5m",
"start": 1329866030000,
"end": 1329866329999
},
"appMetrics": [
{
...
}]
});
My store code:
proxy: {
type: 'jsonp',
url: 'data/smalltest.json',
headers: { Authorization : 'Basic YWRtTEMPNOTREALaW4=' },
callbackKey: 'myCallback',
reader: {
type: 'json',
root: 'appMetrics'
}
}
Small snippet of the json:
myCallback({
"query_info": {
"granularity": "5m",
"start": 1329866030000,
"end": 1329866329999
},
"appMetrics": [
{
...
}]
});