return false for parent javascript function
Posted
by jeerose
on Stack Overflow
See other posts from Stack Overflow
or by jeerose
Published on 2010-04-13T20:28:13Z
Indexed on
2010/04/13
20:33 UTC
Read the original article
Hit count: 293
$("#purchaser_contact").live('submit', function(){
$.ajax({
type: "POST",
url: 'ajax/contactSearch.php',
data: ({ fname: $("#fname").val(), lname: $("#lname").val(), city: $("#city").val(), state: $("#state").val() }),
success: function(d) {
var obj = JSON.parse( d );
if(obj.result != 0){
$("#contactSearch").remove();
$("#button-wrapper").before('<div id="contactSearch">' + obj.result + '</div>');
$("#contactSearch").slideToggle('slow');
//return false from submit!!
});
});
I know there are other posts on this but I couldn't figure out how to apply them properly to my situation without making it messy.
How do I return false on the submit event to prevent the form from submitting if I'm within the $.ajax
and success
functions?
Thanks.
© Stack Overflow or respective owner