PDA

View Full Version : about Ext-yui XHR utility



mysticav
22 Mar 2007, 6:38 PM
I would like to know if ext-yui provides an XHR utility similar to:
http://ajaxtoolbox.com/

basically it works like this:

Ajax.makeRemoteCall(mydataObj, remoteurl, callback);

function callback(response){
.... do whatever yo want with response
}

JeffHowden
22 Mar 2007, 7:21 PM
Sure, look in the docs for the UpdateManager class.

mysticav
22 Mar 2007, 7:41 PM
Well it doesn't look clear form me:


// Get it from a Ext.Element object
var el = Ext.get("foo");
var mgr = el.getUpdateManager();
mgr.update("http://myserver.com/index.php", "param1=1&param2=2");
...
mgr.formUpdate("myFormId", "http://myserver.com/index.php");

How can I just make the call and get the response without involving elements at all?

Or even better, how can you adapt this approach using yui-ext:


Ajax.makeRemoteCall(mydataObj, remoteurl, callback);

function callback(response){
.... do whatever yo want with response
}

JeffHowden
22 Mar 2007, 8:30 PM
If you're not looking to update an element, then you'll probably want to look into Ext.lib.Ajax.request() or Ext.lib.Ajax.formRequest() if you're working with form data.

mysticav
22 Mar 2007, 8:51 PM
Thanks, but can you point me where can I read info. about this object ?

JeffHowden
22 Mar 2007, 9:24 PM
There are no docs at this point. So, you'll need to look directly in /src/experimental/yui-bridge.js

Belgabor
22 Mar 2007, 9:41 PM
You can also use Ext.data.Connection. See my AjaxForm class for an example (update and submit functions).

mysticav
23 Mar 2007, 11:12 AM
Yes. it works as expected. Just have a question:
In the following code, I would like to know about the 'method' parameter.



var conn = new Ext.data.Connection({

method: finalMethod,
url: finalUrl
});

Also I need to know if its possible to make cross ajax calls (normally is not allowed).

Thanks.

tryanDLS
23 Mar 2007, 11:20 AM
Connection determines whether to do GET or POST based on whether you pass parms to the request. In addition, you can pass method:'GET' or method:'POST' to override that behavior. Read the source to see the implications of GET vs POST.