PDA

View Full Version : Extending Ext.data.proxy.Ajax to call a function instead of a ajax request



gtsafas
26 Jul 2012, 11:46 AM
I want to take the request object that gets posted to the server and pass that to a javascript function. Which in turn would handle return the json to whatever callback (async) that the request provides. I have been fiddling with it and cant seem to get it to work.

I saw directFn but it seems to be *almost* what I want. But the docs dont really explain it too well. Also then I am curious about readers, buffering etc. It looks overly complex too. All I want is to call a js function and return the data. Feel like it should be implementable within a few lines since all the webserver does is return json.

gtsafas
27 Jul 2012, 6:07 AM
Anyone have a suggestion?

el_chief
27 Jul 2012, 11:24 AM
What are you trying to accomplish? What is the purpose?

Something like this?

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ux.ajax.SimManager

gtsafas
27 Jul 2012, 12:51 PM
Im not sure this is exactly what im looking for. What I ultimately want to do is something such as this below.



function getData(request) {
.....fetch data on your own parsing request....
async call request.callback with fetched data

}

Ext.Create(..., {
...
'proxy': {
'url': '/data/normal',
'type': 'ajax',
'dataFn': getData,
'reader': {
'totalProperty': 'nrows',
'root': 'rows',
'type': 'json',
'useSimpleAccessors': True
}
},
});



I wish to do this since I wont have to change my backend logic and then I can push the request through my long poll which talks to the back and not take up anymore sockets in the browser