An example how to use the ExtJs classes Ext.Ajax and Ext.util.JSON to load json encoded data into a javascript object from a remote source.

// we do this (in this example) when Ext is ready
Ext.onReady(function(){
// do the Ext.Ajax.request
    Ext.Ajax.request({
        // the url to the remote source
        url: 'data/persons.json',
        // define a handler for request success
        success: 
	        function(response, options){
		    var persons = Ext.util.JSON.decode(response.responseText);
		    // use the persons object...
		    // u can uncomment the following line if firebug is available
                    // console.info(persons);
		}
	// NO errors ! ;)
	// failure: personsRequest_onFailure ... or something else
    });
});

One Response to “Load json with ExtJs.Ajax and Ext.util.JSON”

  1. Viji Says:

    in Book Reviews, ExtJS ***(This book has been replaced by a new one from the same aorhuts titled Learning Ext JS 3.2 and you should order that one and not this one) I’ve been learning ExtJS now for a couple

Leave a Reply