PDA

View Full Version : Ext.AJAX, Ext.Direct, JSON/ARRAY Reader?



alienwebz
25 Feb 2010, 12:36 AM
Im working with some ext components and im not sure how i should go about getting values from my php backend.

I am writing values to an array in php and converting them to JSON format. What I need to know is what would be the best way to get these values? I would like to use them as settings so most of the values will be used in 'if' statements.

danellison
25 Feb 2010, 2:58 PM
Im working with some ext components and im not sure how i should go about getting values from my php backend.

I am writing values to an array in php and converting them to JSON format. What I need to know is what would be the best way to get these values? I would like to use them as settings so most of the values will be used in 'if' statements.

Should be no problem to use either an Ext.Ajax.request call or an Ext.data.DirectStore to get the data. Of note, if you use a DirectStore your routine must return a success property and a property equal to whatever you define your data root to be. Further, you should return a native php array rather than messing with json_encode'ing it on the server.

Ie: return(array('success'=>true, 'data'=>$mydataarray));

Learned that one the hard way after spending much time building JSON objects in php and trying to return them to a DirectStore. Ext.Direct is some major cool work but I understand there is still some work to do with it. I use it where ever practical.

Good luck,
Dan

bookworm2113
29 Apr 2011, 3:25 AM
[QUOTE= return(array('success'=>true, 'data'=>$mydataarray));
Learned that one the hard way after spending much time building JSON objects in php and trying to return them to a DirectStore.
[/QUOTE]
Man you just saved me another night. I spent last night figuring out how to do this and I'm glad I saw this. Let me say that saki's series was a great resource. Check it when you have problems http://blog.extjs.eu/know-how/mastering-ext-direct-part-1/