return false for parent javascript function
- by jeerose
$("#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.