PDA

View Full Version : No request sent while using ScriptTagProxy



irfaniqbal
28 Dec 2010, 6:35 AM
Hi,
I am using ScriptTagProxy to get json data from another domain. But no request sent. I have used it many ways. Also follow many forum posts but the problem is still there :s. Here is my code.



Ext.setup({
glossOnIcon: false,
onReady: function(){
Ext.regModel('Supplement', {
fields: [
{name: 'name', type: 'string'},
{name: 'supplement_timings', type: 'string'},
{name: 'unit', type: 'string'},
{name: 'instructions', type: 'string'}
]
});

var store = new Ext.data.JsonStore({
model: 'Supplement',

proxy: new Ext.data.ScriptTagProxy({
url: "<?=$this->base?>/supplements/getSupplements/<?=$uuid?>"
}),

reader: new Ext.data.JsonReader({
root: 'supplements'
}, [
{name: 'name', mapping: 'name'},
{name: 'supplement_timings', mapping: 'supplement_times'},
{name: 'unit', mapping: 'unit'},
{name: 'instructions', mapping: 'instructions'}
])

});

var list = new Ext.List({
fullscreen: true,
indexBar: true,
store: store,
itemTpl : '<tpl for="."><div><b>{name}</b></div></tpl>'
});

var cont = new Ext.Panel({
fullscreen: true,
layout: 'card',
items:
[list],
dockedItems: dockedItems
});
}
});
The url i used in ScriptTagProxy is a PHP function which gets the Json data from other domain.
I have also validate my Json and there is no problem with it. Can anyone please help me to solve this problem? thanks in advance.

evant
28 Dec 2010, 6:38 AM
You never tell the store to load. Either call the load method or specify the autoLoad option on the store.

irfaniqbal
28 Dec 2010, 7:13 AM
thanks evan. i have added autoLoad: true, but it keep showing me a Loader and display nothing else. i did this before.

irfaniqbal
29 Dec 2010, 2:36 AM
Hi Evan,
i want to give you an update on this issue that finally i got my Json data but my browser got stuck with following Warning & Error:

Warning: "Resource interpreted as script but transferred with MIME type text/html."
Error: Uncaught SyntaxError: Unexpected token :

for further illustration i have attached a screen shot of my browser:
24006

Please reply me as soon as possible because i have got stuck into that problem :(

evant
29 Dec 2010, 2:49 AM
Sounds like you need to do some reading about JSONP: http://remysharp.com/2007/10/08/what-is-jsonp/

irfaniqbal
29 Dec 2010, 5:49 AM
thanks evan. looks like i am very close to solution. now i am out of both warning and error but the problem is that the store loads nothing. I have tried a callback function in Store's load method as in Sencha API Documentation but following code display only empty square brackets [].


store.load({
scope : this,
callback: function(records, operation, success) {
//the operation object contains all of the details of the load operation
console.log(records);
}
});


Also if i use "console.log(store.getCount());" , it also prints 0. and this i think means that store contains nothing. i think i m doing something wrong?

2. one more thing that when we got the response by using scripttagproxy, the Json is wrapped in a callback. the question is whether we extract our actual json data from that callback manually or scripttagproxy handles it?

any quick help is very much appreciated. thanks in advance