I made a simple ajax live search in PHP and javascript.
I used standard js ajax call script such as the one from w3schools.
http://www.w3schools.com/ajax/ajax_aspphp.asp
The function basically gets called onkeyup and php file returns a list of results such as the following:
<a href='javascript:void(0)' onCLick='example()'>example</a>
The problem is that the function exampe() gets called with a single click on ie and chrome whereas on firefox, it requires a double click to call exampe() (as if the page is not focused).
Is this a known issue with firefox? Does anyone experience something similar?
This fiddle http://jsfiddle.net/steveukx/GVbZU/ shows the code you’ve got above working fine, are you sure that the function you’re calling as the
onclickhandler exists? Firebug (or the Firefox built in console) should give you a pointer to any errors being thrown by your JavaScript.Instead of using the
onclickattribute, you could event listeners attached by JavaScript instead, for example:HTML:
JavaScript
Note: the example above assumes that you’re not supporting IE <= 7, if you are, then you should check for the existence of addEventListener or the IE specific attachEvent instead, see http://www.quirksmode.org/js/events_advanced.html