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
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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.