PDA

View Full Version : problem with data loading..|ScriptTagProxy|JsonReader|



wetlook
22 Jul 2007, 11:57 PM
Hi! I have a problem with a data loading into a grid.
i have a json.php file which consist of html-json data.
The data store initialization:


var ds = new Ext.data.Store({

proxy: new Ext.data.ScriptTagProxy({ url: 'http://localhost:8016/json.php'}),
reader: new Ext.data.JsonReader({},
[
{name: 'id',mapping :'id'},
{name: 'type', mapping:'type'}
])

});

but i have no result. Please help me with this problem!
I use IE6. May be problem with it?
I'm trying everything: JsonStore;
Ext.data.Connection with request to server uri and decode response with Ext.util.JSON.decode and putting it into MemoryProxy;
using HttpProxy!
I have to load json to Div conainer from the server (ZF application) and get from Div and decode with Ext.util.JSON.decode and putting it into MemoryProxy - it works great!
Tomorow, I will try to use FireFox with FireDebuger, may be it helps.

gkassyou
30 Aug 2007, 8:01 AM
I'm having the same problem. Although I can view my JSON response in firebug which seems to be ok but the datastore is not reading for some reason. Perhaps because my serverside is slower in returning the data, that the DS does not wait. Any ideas.


var orderDS = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'http://127.0.0.1:8080/IAP_Fulfiller/Order.jsp?fulfillerID='+fulfillerID
}),

// create reader that reads the Topic records
reader: new Ext.data.JsonReader({
root: 'orderInfo',
totalProperty: 'totalCount',
id: 'orderID'
}, [
{name: 'orderID', mapping: 'orderID', type: 'int'},
{name: 'freight', mapping: 'estimatedFreight', type: 'float'}
]),

// turn off remote sorting
remoteSort: false
});

orderDS.load();


stcCallback1001 (

({
"orderInfo":[
{
"orderID":"04022015",
"estimatedFreight":"0.00"
}],"totalCount":"1"})


);

steffenk
30 Aug 2007, 8:06 AM
i had same problem and changed ScriptTagProxy to HttpProxy and it works for me.

gkassyou
30 Aug 2007, 8:08 AM
I have to use ScriptTagProxy since I'm making a call to another port on my server. I'm basically calling JSP running on Tomcat.

steffenk
30 Aug 2007, 8:14 AM
did you read special remarks in teh doku?
http://extjs.com/deploy/ext/docs/output/Ext.data.ScriptTagProxy.html

gkassyou
30 Aug 2007, 8:28 AM
This is driving me NUTS!

I've tried setting the callbackparam and calling my own callbackfunction but no cigar. Although I have set my own callbackparam, I've noticed while debugging that the cb is set to the transid.

Can anyone help with this.

Thx

Animal
31 Aug 2007, 12:09 AM
For a ScriptTagProxy, you have to make your server write the correct output.

It cannot write the Json data, it must write executable javascript code.

If the data benig returned was



{foo:"bar"}


You must send back somethig like:



callbackFunction({foo:"bar"});


The name of the callback function is passed as an HTTP parameter. Check the docs.

gkassyou
31 Aug 2007, 4:32 AM
isn't that what I'm doing with the following:


stcCallback1001 (

({
"orderInfo":[
{
"orderID":"04022015",
"estimatedFreight":"0.00"
}],"totalCount":"1"})


);

Animal
31 Aug 2007, 4:44 AM
Yes, that looks like it should work.

You'll have to step through it with Firebug to fnid the problem.

gkassyou
31 Aug 2007, 4:47 AM
I'm using Ext 1.0.1.

I have but did not find any errors. Where should I be looking in the step through. This is driving me mad.

gkassyou
31 Aug 2007, 5:11 AM
Since the ScriptTagProxy adds a script to the <HEAD> of the document, I was missing the tag. This is a bug.

gkassyou
31 Aug 2007, 5:30 AM
That didn't solve it. It read it once and not anymore. WHY!!!

gkassyou
31 Aug 2007, 5:37 AM
It's not calling the following function in the load function.
window[trans.cb] = function(o){
conn.handleResponse(o, trans);
};

Animal
31 Aug 2007, 5:49 AM
In that statement trans.cb is the name of the function. Check what it is, then check that the response is calling that.

Does Firebug tell you that the script is being returned?

gkassyou
31 Aug 2007, 6:34 AM
ok it's actually calling the response and it is reading the result json ok. There is a wait for the result so I have added the on('load', function()) to get the orderID. I wasn't able to view the DS details in firebug because of the wait to get the response.