I have an onclick handler which executes and jquery ajax load function but I need to validate a form first before executing the load function. I don't know how to prevent the load from occurring until the validate is complete. I am validating using the jquery validate plugin. Any ideas?
The jQuery validate documentation page has a section called "Plugin Methods". At the top of that list of methods is one called "validate( options )" that you can click on to get more details.
The "validate( options )" page has two tabbed sections, called Overview and Options.
In the Options tab is one called submitHandler which shows some code to achieve what looks to be precisely what you need.
Thanks for pointing me in the right direction, got it sorted :). I have been working on an opencart mod.
The fact that a bit cms system like opencart relies on ajax for its checkout funcion showed me that a lot of people aren't considering users with js disabled nowadays and I have always learnt that I should take this into consideration.
I can see that you're a very experienced js developer, what do you think?
Thanks I really appreciate the advice.
BTW how do you debug your scripts? I have been using firebug and console.log() to dump variables but I would like to learn how to trace through properly, I have tried the Venkman debugger and can't seem to get it to work. Do you know of any good tutorials on tracing though with either Venkman or firebug or anything similar?
I debug them using the built-in debugger that comes with Google Chrome.
Script Panel - FirebugWiki
A tutorial on using it is at:
Typically I breakpoint at a certain place, then use the step commands to walk on through the execution to help narrow down the cause.
That one is just about identical in how it works to the Venkmann extension for Firefox (and also as similar to the ones built into Safari, IE8, and Opera).
About the only difference between them all is where you find the option to open them.
Thanks for the advice both,