javascript - GET xmlHTTPrequest not working -


i trying make ajax commenting system if new comment posted, document title changes (1) website title (like twitter)

my code here

the xmlhttprequest

 function loadxmldoc7(url)         {         if (window.xmlhttprequest)           {// code ie7+, firefox, chrome, opera, safari           xmlhttp=new xmlhttprequest();           }         else           {// code ie6, ie5           xmlhttp=new activexobject("microsoft.xmlhttp");           }         xmlhttp.open("get",url,false);         xmlhttp.send(null);         document.getelementbyid('newcomments').innerhtml=xmlhttp.responsetext;         } 

the php

    echo "<script type='text/javascript'>     function auto2comments()     {      var mydiv1 = document.getelementbyid('uiuiui');";     echo "loadxmldoc7(mydiv1.innerhtml)";     echo "}";     echo "setinterval(\"auto2comments()\",15000);</script>";     } 

the div uiuiui contains /newcommentingi.php?show=0&id=username problem when newcomments div gets filled, shows
id =
show = 0
why?

the xmlhttprequest object asynchronous, means when has data ready, returns in method. best create function act event handler when server responds, calls event handler function.

i think solution need similar here: how response of xmlhttprequest?


Comments