How to Connect Ajax to MySQL

The Ajax language processes HTML forms and passes the forms' information to a database processing page. To connect the Ajax language to your MySQL database, pass the Ajax data to your PHP data connection page. Ajax is similar to JavaScript, so JavaScript programmers can add the language to their pages conveniently and without many changes to the overall website code.

Instructions

    • 1

      Right-click the HTML page or Ajax external page you want to use to connect to MySQL. Click "Open With" and choose your preferred editor.

    • 2

      Create the Ajax variable. You create a variable to initialize the ActiveX or browser add-on that connects to the PHP data connection page. Add the following code to the Ajax function:

      var ajax;

    • 3

      Set up the "HTTPRequest" plugin. Each browser has the Ajax connection utilities, so the browsers are compatible with your Ajax functions. Add the following code after the variable definition statement:

      ajax = new XMLHttpRequest();

    • 4

      Send the form information and connect to the database. Place the following code at the bottom of your Ajax function:

      ajax.open("GET", "dataconnection.php" + str, true);

      Replace "dataconnection.php" with the name of your own connection page; replace "str" with the form input string.

Related Searches:

References

Comments

Related Ads

Featured