Jump to content

Xmlhttprequest Send() Method


heldplayer

Recommended Posts

i'm learning the XMLHttpRequest but I don't understand how to use the send method, I know when to use it but not how, so I ask a couple of things:1. How do you use it?2. Does it need PHP or ASP to work?3. Can I use it with just javascript and HTML?4. Can I edit an XML file with it?thanks anyway

Link to comment
Share on other sites

You just need to call the send method of the XHR object at some point after calling the open method. If you're sending a get request, you send a null value to the send method. If you're sending a post request, you send the post data to the send method. You don't need any server requirements to use ajax, it's only Javascript. You can't use the send method to edit an XML file, send just sends a request to the server.

Link to comment
Share on other sites

actually i believe one can send data in the querystring via the GET and use the SEND method simultaneously - GET variables are in the querystring of the url POSTed to, it's how i do my xml generators. that way i can post to a form handler saying add a new record or modify a record or delete a record or simply reload the updated records (GET) with the data posted (POST) to this url. it works quite well, but its rather advanced - i would recommend newbies in AJAX to rather use GET than a POST request, especially if using GET aswell; for training, the latter two are a bit harder with headers, content types etc being sent before the data stream. requesting a PHP or ASP or whatever page that is processed server side with a query string instead of a POST method will allow you to send data that way. beware however, i believe the GET method is limited in the sense that you can't have a url longer than 64 characters in some browsers. so small forms: small steps - keeping it simple, is best when learning xml_http basics :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...