使用ajax在div中打开一个url

时间:2013-03-15 19:01:25

标签: jquery html ajax

<html>
<head>
<script>
function showUser(str,st1)
{
if (str=="" AND st1=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET","http://www.tndte.com/Result/Default2.aspx?Value="+str"regul="+st,true);
xmlhttp.send();
}
</script>
</head>
<body>
<center>
<form>
Enter the Register No: &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="reg"/><br /><br />
<input type="radio" value="K"  name="s1" >K/L/R/O/N-scheme &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="J" name="s1" >J/C/D/G-scheme
<br /><br />
<input type="submit" value="View" name="submit" id="valuebtn" onClick="oload()" /> 
</form>
</center>

<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>

</body>
<script type="text/javascript">
function oload(){
    document.getElementById('valuebtn').onclick = function() {
    var s = document.getElementById('reg').value;
    var ss = document.getElementById('s1').value;
    showUser(s,ss);
    }
}   
</script>
</html>

上述程序是为了在原始网站的帮助下自行检查结果而编写的。在ajax XMLHttpRequest的帮助下,我将值传递给函数。但它没有回应。任何人都可以帮助我。?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

AND不是javascript关键字。在&&声明中使用if