FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


What a Heck with javascript..





Philip
i try to refresh a page with ajax, but it seem javascript doesnt refreshed, i tried it 5 days already. wew... so dam it.

test to save this file with php extension.

Code:
<div id="Info">
<html>
<head>
</head>
<?
$random=rand();
 echo '
      <script language="javascript">
      function prin'.$random.'()
      {
         alert(\''.$random.'\');
      }
      </script>
 ';
?>
<script language="javascript">
function refresh(){
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
   {
         return true;
   }
   var url="test2.php";
   url=url+"?sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null);
   return false;
}

function stateChanged()
{
   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")   
   {
      document.getElementById("Info").innerHTML=xmlHttp.responseText;
   }
}

function GetXmlHttpObject()
{
   var objXMLHttp=null;
   if (window.XMLHttpRequest)
   {
      objXMLHttp=new XMLHttpRequest();
   }
   else if (window.ActiveXObject)
   {
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   return objXMLHttp;;
}

</script>
<body>
<? echo $random; ?>
<br>
<A onClick="<? echo 'prin'.$random.'()'; ?>" href="#">
test print
</A>
<br>
<A onClick="refresh();" href="#">
Refresh
</A>
</body>
</html>
</div>


please some one suggest me how can i change the value of javascript on ajax , thanks
Related topics
Drag images (Javascript)
PB PHP, Iframe and Javascript
Clock-javascript
javascript: needed script for displaying window
Handling Css using Javascript
Navigation Script (javascript) Help Please!
resolution detection with javascript
A Useful Javascript
Tutorial: Image Rollovers w/ Javascript
Save webpage source into javascript variable
Professional JavaScript For Web Developers
Okay, I'm done trying to use CSS for layout.
Nice site for Javascript
Language
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.