jQuery event.preventDefault() not working in Firefox (JSFiddle included)
Solution 1:
The variable event
in your code is not initialized.
http://jsfiddle.net/SeEw2/4/
extract :
$('#ajaxsearch').click(function(event) {
// Stop the Search input reloading the page by preventing its default action
event.preventDefault();
Solution 2:
Ah I've had a similar problem in that past. Rather than event.preventDefault() try passing the event to:
function ie8SafePreventEvent(e){
if(e.preventDefault){ e.preventDefault()}
else{e.stop()};
e.returnValue = false;
e.stopPropagation();
}
I know it says IE, but I've never had a problem with it since =]
Solution 3:
Instead of looking for a click event on the submit button, why not use the $(form).submit handler?
As long as you have 'return false' at the end of the handler, the page won't reload.
Solution 4:
Because your not passing the event object like function(event)
, but my question is why even go through all this when you can make the type="button"
and onclick pass the values? In essence that what your doing with this whole process.