Results 1 to 2 of 2

Thread: MySQL AJAX insert and refresh

  1. #1
    Join Date
    Oct 2008

    MySQL AJAX insert and refresh

    Hi All

    I hope you can help.

    I've got a <select> code that pulls the options from a MySQL database. If an option that is needed isn't there, I would like to create a script that adds the option to the database and then refreshes the select box to include the new option without refreshing the page.

    Is this possible?
    Is this where AJAX would come in?

    I have a very good understanding on PHP and MySQL. A basic knowledge of Javascript and no idea about AJAX.

    Any help would be much appreciated.


  2. #2
    Join Date
    Oct 2009
    This will help.
    function getXmlHttpRequestObject() {
    	if (window.XMLHttpRequest) {
    		return new XMLHttpRequest(); //Mozilla, Safari ...
    	} else if (window.ActiveXObject) {
    		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
    	} else {
    		alert("Your browser doesn't support the XmlHttpRequest object.");
    function makeRequest(url, param) {
    	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
    		receiveReq.open("GET", url, true);
    		receiveReq.onreadystatechange = updatePage; 
    		<your headers>
    function updatePage() {
    	if (receiveReq.readyState == 4) {<do the updating>;
    function getSelect() {
    	var url = '<your url>';
    	var postStr = '<your postStr if there is one>';
    	makeRequest(url, postStr);
    var receiveReq = getXmlHttpRequestObject();
    Good Luck

    Santos Systems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center