Sami Posted November 18, 2010 Share Posted November 18, 2010 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 More sharing options...
jeffman Posted November 18, 2010 Share Posted November 18, 2010 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 More sharing options...
Sami Posted November 18, 2010 Author Share Posted November 18, 2010 Can you give an example? Link to comment Share on other sites More sharing options...
jeffman Posted November 18, 2010 Share Posted November 18, 2010 You really could Google this and find thousands of examples yourself. Here is one tutorial. Link to comment Share on other sites More sharing options...
Fmdpa Posted November 18, 2010 Share Posted November 18, 2010 W3Schools also has a good tutorial. If you want to let AJAX interact with a server-side language such as PHP, you can read about that here. Link to comment Share on other sites More sharing options...
Sami Posted November 21, 2010 Author Share Posted November 21, 2010 Yeah, but if somebody enter something with comma, guess what's happening ?And deirdre's dad: Thx Link to comment Share on other sites More sharing options...
Synook Posted November 21, 2010 Share Posted November 21, 2010 Yeah, but if somebody enter somethink with comma, guess what's happening ?What happens? Link to comment Share on other sites More sharing options...
Sami Posted December 24, 2010 Author Share Posted December 24, 2010 nvm Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.