Jump to content

Submit a form trough AJAX


Sami

Recommended Posts

I wish to submit a form in a shoutbox, but instead of sending the user back after enter a comment, I wish that AJAX should submit the form and use the respond to see if it was successfully added to the database.How can I do this?

Link to comment
Share on other sites

An httpRequest object sends your data. If you are assembling the data yourself, make it look like a query string, ie:name1=value1&name2=value2&name3=value3and so on. Each value should first be encoded, using encodeURIComponent. Send the data, and your server environment will find it in your POST or GET data, depending on the configuration of your request object.Your server-side system will process the data and print a response. The response SHOULD NOT be a complete HTML document. It can be a small string, or even a character, or you can simply return a header. It could be a string with HTML tags embedded in it. Complex data can be formatted as XML or JSON. Data returned from your server will be found in one or more of your request object. Depending on what you sent, get it in one of these ways:

myrequest.responseText // should be a string)myrequest.responseXML //should be an XML DOM objectmyrequest.getResponseHeader(my_header_name) // should be a string

There are special ways to configure a request object, and you should read about those in the tutorials.

Link to comment
Share on other sites

Yeah, but if somebody enter somethink with comma, guess what's happening ?
What happens?
Link to comment
Share on other sites

  • 1 month later...

Archived

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

×
×
  • Create New...