Join 300,362 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,483 people online right now. Registration is fast and FREE... Join Now!
i use this syntax "java script:showHint(this.value)" on another javascript function which is in the same file as this one and it works. So i don't see where's the error here.
the javascript function show hint looks like this
CODE
var xmlHttp; function showHint(str) { if (str.length<=2) { document.getElementById("apDiv45").innerHTML=""; return; } xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; }
var url="gethint.php"; url=url+"?search="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); }
function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("apDiv45").innerHTML=xmlHttp.responseText; } }
function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
and gethint.php like this (it just echoes 'this is a test', too be sure that here there's no error):
CODE
<?php header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); echo 'this is a test'; ?>
so... the codes above should put me in a div (apDiv45) 'this is a test' when i pres a key on my keybord, but it does nothing. Do you have any ideea where's the mistake?
I know see that in works only in IE7. Not in Firefox.
What must i change to work in firefox too?
This post has been edited by livium: 1 Jul, 2009 - 06:15 AM
Thanks you very much for your effort. I've tried your code but it doesn't work still in firefox, only in IE. My javascript function is found on w3schools and everywhere on the internet. It is something standart i guess, and it worked in firefox on a similar implementation, when i made an ajax tutorial some time ago. But now i just don't know why it doesn't work anymore. I thinks it's something wrong with firefox ( a setting or something).
This post has been edited by livium: 1 Jul, 2009 - 06:59 AM
Um..that's not what I meant... Firebug is an addon for Firefox that lets you do a lot of useful stuff, it also helps debug javascript a lot of the time.
But more importantly that's absolutely nothing to do with Javascript it's a PHP error, you're just not giving an index to which column you want to select and are passing an array instead.
Anyway, since you haven't posted all of your code, how do you expect us to help you? The example I give you works perfectly fine, I've proved this to you and you yourself said that it worked.
This post has been edited by MageUK: 1 Jul, 2009 - 07:35 AM
my code is the first one posted. So, it puts me 'this is a test' in ie but not in ff. In ff it puts this text only in page source which i view through firebug. So it cannot be a php error.
I've tried your code and i had the same problem. So i stick with mine then. Why don't you try my javascript function and see that it works on your code. I bet it works.