Hello. I'm having a bit of trouble grasping Yahoo's connection
manager. I've had quite a bit of experience with our current
implementation of AJAX where we compile a string of XML on the
frontend and then pass that to a "service" as an EZMessage on the
backend. They then return us a response.
How do I achieve a similar goal with YUI's connection manager? How do
I compile my information and submit it to a specific back-end service?
--- In ydn-javascript@yahoogroups.com, "daniel" <dep@...> wrote:
>
> Hello. I'm having a bit of trouble grasping Yahoo's connection
> manager. I've had quite a bit of experience with our current
> implementation of AJAX where we compile a string of XML on the
> frontend and then pass that to a "service" as an EZMessage on the
> backend. They then return us a response.
>
> How do I achieve a similar goal with YUI's connection manager? How do
> I compile my information and submit it to a specific back-end service?
// I'm not familiar with the EZMessage format,
// so this is just a basic assumption that
// an XML document is all there is to the data.
var data = <your XML document here> ;
/*
* if you need to send custom headers,
* use YAHOO.util.Connect.initHeader(label,value);
*/
// Handle the response
var callback = {
success:function(o){
//do something for HTTP 2xx
},
failure:function(o){
//do something for HTTP 4xx/5xx
}
};
// Send the request
var request = YAHOO.util.Connect.asyncRequest(
'POST',
<urlToYourServiceHere>,
callback,
data
};
--- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
>
> --- In ydn-javascript@yahoogroups.com, "daniel" <dep@> wrote:
> >
> > Hello. I'm having a bit of trouble grasping Yahoo's connection
> > manager. I've had quite a bit of experience with our current
> > implementation of AJAX where we compile a string of XML on the
> > frontend and then pass that to a "service" as an EZMessage on the
> > backend. They then return us a response.
> >
> > How do I achieve a similar goal with YUI's connection manager? How do
> > I compile my information and submit it to a specific back-end service?
>
> // I'm not familiar with the EZMessage format,
> // so this is just a basic assumption that
> // an XML document is all there is to the data.
> var data = <your XML document here> ;
>
> /*
> * if you need to send custom headers,
> * use YAHOO.util.Connect.initHeader(label,value);
> */
>
> // Handle the response
> var callback = {
> success:function(o){
> //do something for HTTP 2xx
> },
> failure:function(o){
> //do something for HTTP 4xx/5xx
> }
> };
>
> // Send the request
> var request = YAHOO.util.Connect.asyncRequest(
> 'POST',
> <urlToYourServiceHere>,
> callback,
> data
> };
>
> Regards,
> Thomas
>
It works. I did, however, have to change _default_post_header: in
connection.js to "text/xml".