www.developer.com/lang/article.php/3600611
By Nicholas Zakas April 21, 2006 Form InteractionIt is becoming more and more common to submit form values through an Ajax request instead of using the traditional form posting technique. The Yahoo! Connection Manager makes this easy by allowing you to set a form whose data should be sent through the request. For instance, suppose you have a form with the ID of "frmInfo". You could set up a POST request to submit the data contained in the form like so:
Using the It's important to note that the data string is constructed when you call Additional FeaturesPresently, Internet Explorer uses ActiveX objects for XMLHttp. These ActiveX objects have string-based signatures that must be used to create the object using JavaScript. Since the Connection Manager handles this creation for you, generally you don't need to know what these signatures are. However, if a change to the signatures occurs in the future, you can specify the most recent signature by using
Here, the Connection Manager will attempt to create an ActiveX object with the signature "some.future.ActiveX.signature" before it attempts to create an object from the known list of signatures. This is something that Yahoo! provided to future-proof the library (though Internet Explorer 7 will feature a native You can also send header information by using the
In this example, an extra header with a name of "MyName" and a value of "Nicholas" is sent to the server. Note that this header is only good for one request; all headers reset to default values after each request. There's no need to set the "Content-type" header for POST requests. The Connection Manager handles this for you behind the scenes. LimitationsWhile the Yahoo! Connection Manager does make some requests easier, it does have its limitations. Currently, only asynchronous requests are supported, so you'll be stuck using old school XMLHttp is you need to make a synchronous request. Though many argue that synchronous requests should never be used, sometimes there are practical reasons for it. It is also worth noting that this is version 0.9 of the Connection Manager, so undoubtedly there will be some additions and changes in the future. However, for the time being, it remains one of the most compact libraries for cross-browser XMLHttp available. About the AuthorNicholas C. Zakas is the author of Professional Ajax by (Wiley Press, ISBN: 0-471-77778-1) and Professional JavaScript for Web Developers (Wiley Press, ISBN: 0-7645-7908-8). Adapted from Professional Ajax written by Nicolas C. Zakas . Copyright 2006 by Wiley Publishing, Inc. All rights reserved. Reproduced here by permission of the publisher. |
| Go to page: Prev 1 2 3 |