Jack Jack - 1 year ago 99
jQuery Question

jQuery event.preventDefault() not working in Firefox (JSFiddle included)

This is a kind of similar duplicate to some others here, but I think I'm using

correctly in this case.

Here's a JSFiddle you can see the code with: http://jsfiddle.net/SeEw2/2/

Basically, click the Submit button.

In Chrome: Nothing happens - correct response.

In Firefox: Page reloads, oh noes!

So why is the page reloading in Firefox and not Chrome? I've been Firebugging it and no errors come up in either...

Answer Source

The variable event in your code is not initialized.


extract :

 $('#ajaxsearch').click(function(event) {

        // Stop the Search input reloading the page by preventing its default action
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download