javascript - document.GetElementById("main").innerHTML = "testing" is reverting, not changing permanently -


below java.html code inserting <a href='' onclick='load_des()'><li><p>$row[title]</p></li></a> element in div element id "main" echoing php script ajax response can see in below code. insertion successful, when click element load_des() function called, showing "testing" word blink , again showing link. intention show "testing" word permanently, don't know happening in ajax code? click link, click java option under domains, find link named test, link explaining above

<!doctype html> <html> <head> <title></title> <script type="text/javascript"> function on_load(){    var xmlhttp;   if (window.xmlhttprequest)    {// code ie7+, firefox, chrome, opera, safari         xmlhttp=new xmlhttprequest();    }   else    {// code ie6, ie5       xmlhttp=new activexobject("microsoft.xmlhttp");    }    xmlhttp.onreadystatechange=function()    {       if (xmlhttp.readystate==4 && xmlhttp.status==200)       {          document.getelementbyid("main").innerhtml=xmlhttp.responsetext;        }    }   xmlhttp.open("get","load_ques.php",true);   xmlhttp.send();   }   function load_des(){      document.getelementbyid("main").innerhtml="testing";       return false;  }   </script>  </head>  <body onload="on_load()">  <div id="main">   </div>  </body>  </html> 

try this, change load_des() return load_des(). prevent current page loading again.

<a href='' onclick='return load_des()'><li><p>$row[title]</p></li></a> 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -