Jump to content

Need help with XMLHttpRequest, using PHP


Orionsbelter

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/196175-need-help-with-xmlhttprequest-using-php/
Share on other sites

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!

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

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.