Orionsbelter Posted March 22, 2010 Share Posted March 22, 2010 Hi i'm very new to the XMLHttpRequest of AJAX, could someone please give me some help on how i can use this to update a field and a mysql database. For example: i have a HTML Text field called "Test" onChange, the programme will use the XMLHttpRequest to update a table in my database. I have a script that allows me to use the XMLHttpRequest and a PHP Script to grab from the databse but none to help me input into a database. Quote Link to comment Share on other sites More sharing options...
o3d Posted March 22, 2010 Share Posted March 22, 2010 I would recommend not using XMLHttpRequest on its own but rather use a wrapper like Prototype. For your example it could be as follows: 1. onChange fires a js function that calls e.g. prototypes' request method (in there you specify the php file). 2. You'll also need to create a div or an html container to accept the results from the ajax request. This you also specify in the request method (I think it's called onSuccess: function(response_transmission) {} ). 3. Then when an onChange event occurs, the php file will update the table and then you could return a message stating whether the update was successful or not. Simple as that! Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted March 23, 2010 Author Share Posted March 23, 2010 Thank you for your reply! Could you supply me with some example code or somewhere to learn this? Thank you Quote Link to comment Share on other sites More sharing options...
o3d Posted March 23, 2010 Share Posted March 23, 2010 Except if you get an actual working example you will not find anything easier to learn than this link: http://www.prototypejs.org/learn/introduction-to-ajax Fyi: this is obviously using the prototype library. There are many others out there. Every developer has their own preference. Some "hello world" examples found on the web: http://www.websiteoptimization.com/secrets/ajax/prototype-ajax-library.html http://codingforums.com/showthread.php?t=134024 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.