<?
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?

Recommended Answers

All 2 Replies

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.

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)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.