On the previous post - Thanksgiving Weekend Crash Course - Android, Sencha Touch, PhoneGap and CouchDB I used the JSONP(Ext.util.JSONP.request) as the example, since it can be debugged under Chrome(or Firefox) then port to the Android. To test the Ajax function(Ext.Ajax.request) I have changed the codes as following
function makeAjaxRequest() { Ext.Ajax.request({ url: 'http://127.0.0.1:5984/facebook/_design/acdc/_list/basic/facebook/all', method: "GET", params: {}, success: function(res, request) { if (res) { result = Ext.util.JSON.decode(res.responseText); arr = []; for (i=0; i< result.rows.length; i++){ arr.push({id: result.rows[i].id, img: result.rows[i].img, game: result.rows[i].game, lastName: result.rows[i].lastName, firstName: result.rows[i].firstName}); } layout(arr); } else { alert('There was an error retrieving the data.'); } }, failure: function(res, request){ alert('Failed: ', res.responseText); } }); } Ext.onReady(function() { makeAjaxRequest(); });and under CouchDB a new "list" named "basic" needs to be created to work with the Ajax call, this "basic" list function will generate a JSON object instead of a Javascript function codes -
Thanksgiving Weekend Crash Course - Android, Sencha Touch, PhoneGap and CouchDB
No comments:
Post a Comment