Saurabh Sharma Saurabh Sharma - 1 year ago 107
Javascript Question

lnk with database with ajax in html

the code is showing this error ,dont know how to make it right "GET http://d/xampp/htdocs/cart/getuser.php net::ERR_NAME_NOT_RESOLVED showUser @showuser.php:27 onclick @showuser.php:9". even in my computer the location of file is "http://d/xampp/htdocs/cart/getuser.php" . i am using xampp


enter digit : <input type='text' id='id' /> <br />
<input type='button' onclick='showUser(this.value)' value='select'/>

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

function showUser() {
httpRequest = new XMLHttpRequest();

if (!httpRequest) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
httpRequest.onreadystatechange = alertContents;"GET", "http://D:/xampp/htdocs/cart/getuser.php",true);
function alertContents() {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;




Answer Source

Your URL is not valid.


The D:/ is not valid. You can't use : in a URL. And you can't just directly reference a file on disk either - you reference a URL, which is not the same thing at all.

Does changing it to


work? You've suggested something like this might be the right link. You need to check that your webserver is running and actually serving content at this link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download