0
<?
include('connect.php');
?>
<!DOCTYPE html>
<html>
<head>
<script>
function showCustomer(str)
{alert("dfertvgrevbtr");
var xmlhttp;    
if (str=="")
  {
  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","getcustomer.asp?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<form action=""> 
<select name="customers" onchange="showCustomer(this.value)">
<option value="">Select a customer:</option>
<option value="ALFKI">Alfreds Futterkiste</option>
<option value="NORTS ">North/South</option>
<option value="WOLZA">Wolski Zajazd</option>
</select>
</form>
<br>
<div id="txtHint">Customer info will be listed here...</div>

</body>
</html>

this is my code but m not getting any output. what is the problem?

3
Contributors
2
Replies
21
Views
2 Years
Discussion Span
Last Post by Taywin
0

The alert is triggering, are you getting a response at all on that ajax? One of the more common problems is making cross-domain ajax calls. Try running your pages from a (i.e. both pages on the same) server (localhost will do) and see if the problem persists. If you want to allow cross-domain requests from the asp side you could read this article.

At least that should give you an idea whether the problem lies with the ajax call or if it's something on that asp page.

0

There are TOO MANY possible reasons. One is already stated by Traevel (cross-domain call)...

1) You are using PHP script but you are calling on ASP? This part smells fishy.
2) What browser did you use to test this?
3) Do you intend to make a synchroneous ajax call? You set the flag to "true" when you call for open().
4) What was returned by the page you are sending the request to (the .asp)?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.