www.webdeveloper.com
Results 1 to 3 of 3

Thread: Why would the DIV not refresh with this Ajax call??

  1. #1
    Join Date
    Mar 2012
    Posts
    6

    Question Why would the DIV not refresh with this Ajax call??

    Hello,

    I'm wondering why this Ajax call isn't refreshing his data from de MYSQL database

    I have a form, in this form I have a HighSlide button with calls another popup with a form to add something to the other form.

    Code:
    <script type="text/javascript">
    hs.Expander.prototype.onAfterClose = function MakeRequest_onderdelen() {
    }
    </script>
    The code for the AJAX call is:

    Code:
    <script id="source" language="javascript" type="text/javascript"> 
    function getXMLHttp() {
      var xmlHttp
      try { //Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
      } catch(e) { //Internet Explorer
        try {
          xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
          try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch(e) {
            alert("Your browser does not support AJAX!")
            return false;
          }
        }
      }
      return xmlHttp;
    }
    
    function MakeRequest_onderdelen() {
      var xmlHttp = getXMLHttp();
      xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState == 4) {
          HandleResponse(xmlHttp.responseText);
        }
      }
      xmlHttp.open("GET", "toernooi-onderdelen-ajax.php", true);
      xmlHttp.send(null);
    }
    
    function HandleResponse(response) {
      document.getElementById('output_onderdelen').innerHTML = response;
    }
    </script>
    In the body of the php I have this DIV :
    PHP Code:
    <div id="output_onderdelen"></div
    When I open this page it shows all the records that are in the database. When I click on the Highslide button to add another record and close this Highslide it don't refresh the div.

    When I refresh the page, the added record is visible so this is working :

    Code:
    <script type="text/javascript">
    $(document).ready(function() {
    	MakeRequest_onderdelen();
    });
    </script>
    Anyone any idea why this isn't working:

    Code:
    <script type="text/javascript">
    hs.Expander.prototype.onAfterClose = function MakeRequest_onderdelen() {
    }
    </script>
    The function MakeRequest_onderdelen() is working when the page loads but not when the Highslide is closed.

    Any ideas ???

    Kind regards,

    Arie

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Code:
    <script type="text/javascript"> hs.Expander.prototype.onAfterClose = function MakeRequest_onderdelen() { } </script>
    I think what you meant to do was:

    Code:
    <script type="text/javascript"> 
    
    hs.Expander.prototype.onAfterClose = function()
    { 
      MakeRequest_onderdelen();  
    } 
    
    </script>

  3. #3
    Join Date
    Mar 2012
    Posts
    6
    Hi there,

    That works great !!

    Thx a lot for getting me on the right track, as you see I'm just a beginner with Javascript but learining every day ........

    Kind regards,

    Arie

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



Recent Articles