PDA

View Full Version : How do you fetch the response from the server?



Grubolsch
2 May 2007, 8:11 AM
How do you get the response from the server with an AJAX call? I need to get the plain text that my server returns, to put it into an element. However, whatever I do, I don't see the solution to fetch the returned message. If I look trough firebug, I see the the correct information sended, so the information is somewhere, but where?


var dfg = Ext.lib.Ajax.request('GET','getshoutboxmessage.php', function(response){
$('shoutbalk').getElementsByTagName('cite')[0].innerHTML = response;
});

Thanks for helping a extjs starter :)

TopKatz
2 May 2007, 8:37 AM
With out a call back:



var conn = new Ext.data.Connection();
conn.on('requestcomplete', function(o,response,options) {

doStuff();
});

conn.request({
url: "ajaxRequest.php",
scripts:true,
params: parms,
scope:this
});


With a call back:


var conn = new Ext.data.Connection();
conn.request({
url: "ajaxRequest.php",
scripts:true,
params: parms,
callback: doStuff
});

Grubolsch
2 May 2007, 9:49 AM
Thank you verry much :)

jsakalos
2 May 2007, 11:35 AM
I guess there is much simpler method:



Ext.get('your-target-element-id').load({url:'your-url'});

TopKatz
2 May 2007, 12:48 PM
Thats the third type, an update. It will return an html element and update the div supplied to it. It can also be sent params and other config items like scripts true.


Ext.get("my-div").load({
url: "ajaxRequest.php",
scripts:true,
params: parms,
text: "Loading User Info....."
});

Very useful. It is well documented. There is good documentation on all of them now.