We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,324 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

AJAX getting data problem

on body load it is getting value of function tryt2(l)
but iwant that on body load it get both function value
and onclick i want to play animation.gif while getting data from 001.php but after getting data img will be removed
plz tell me ASAP

<html>
<head>
<script type="text/javascript">
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }


function tryt(l)
{
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }

  }
xmlhttp.open("POST","001.php?q=1 & l="+l,true);
xmlhttp.send();
}

function tryt2(l)
{
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv2").innerHTML=xmlhttp.responseText;
    }

  }
xmlhttp.open("POST","001.php?q=2 & l="+l,true);
xmlhttp.send();
}
function yourFunction(){
tryt();
tryt2();
}

</script>
</head>
<body onLoad="yourFunction()">

<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onClick="tryt(this.value)" value="1">Change Content</button>

<div id="myDiv2"><h2>Let AJAX2 change this text</h2></div>
<button type="button" onClick="tryt2(this.value)" value="2">Change Content</button>

</body>
</html>
1
Contributor
1
Reply
1 Day
Discussion Span
1 Year Ago
Last Updated
3
Views
ak47carbon
Junior Poster in Training
60 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

sadffdf

ak47carbon
Junior Poster in Training
60 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1427 seconds using 2.67MB