Jump to content

lam0rak

Members
  • Posts

    3
  • Joined

  • Last visited

lam0rak's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thanks so much mate!! I tried this and fiddled around with it a bit more and have managed to get it working! you're a legend! cheers!
  2. http://www.insecureinc.com/AJAX/scripts/getcustomer.php?q=24http://www.insecureinc.com/AJAX/scripts/getcustomer.php?q=25http://www.insecureinc.com/AJAX/scripts/getcustomer.php?q=26Thats a direct link to the php script at the moment its accessing an old table I used to store news about an even older site. I just picked the id's as 24, 25, 26 in the select box because they correspond to different data in that table. If you click the link you'll see the php side works fine. I think line 24 might be in the JS file in this function:function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") < line 24?{ document.getElementById("txtHint").innerHTML=xmlHttp.responseText} }
  3. Evening all!It's my first attempt at AJAX and normally I find w3Schools examples really good but I cannot for the life of me seem to get any of their AJAX examples working. I don't know asp so I wrote a server script file in php which it says on the site is possible but when I run the whole thing in IE it say's unspecified error on line 24. In firefox it says nothing it simply just doesn't work. I'm fairly sure my php is sound can anyone check my javascript who is more wise in these things?! I'll post the whole thing here anyway!INDEX.HTM <html><head><script src="./js/selectcustomer.js"></script></head><body><form>Select a Customer:<select name="customers" onchange="showCustomer(this.value)"><option value="24">Preferences<option value="25">SERIOUS TECH...<option value="26">Dubious Poll</select></form><p><div id="txtHint"><b>Posts will load here...</b></div></p></body></html> SELECTCUSTOMER.JS var xmlHttpfunction GetXmlHttpObject(){ var objXMLHttp=nullif (window.XMLHttpRequest){objXMLHttp=new XMLHttpRequest()}else if (window.ActiveXObject){objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")}return objXMLHttp}function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ document.getElementById("txtHint").innerHTML=xmlHttp.responseText} } function showCustomer(str){ xmlHttp=GetXmlHttpObject()if (xmlHttp==null){alert ("Browser does not support HTTP Request")return} var url="../scripts/getcustomer.php"url=url+"?q="+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true)xmlHttp.send(null)} GETCUSTOMER.PHP <?phpinclude "../includes/connect.inc";$q=$_GET["q"]; $sql = mysql_query("SELECT * FROM bucs_customers WHERE updateID='$q'"); $response = mysql_fetch_assoc($sql); echo "----------------------------- \n"; echo "AJAX Test Call\n"; echo "----------------------------- \n \n"; echo $response['customer']." (".$response['datejoined'].") \n"; echo $response['email'];?> I'm really greatful for any and all help on this guys my javascript knolwedge is pretty minimal so if I am missing something I cant spot what it is! please help!!Rich
×
×
  • Create New...