javascript - Submitting form with ajax and jQuery -
i have simple form 1 select box , 2 options in it. here related jquery code:
$('.mycssclass').on('change', function() { alert("this executed"); $(this).parent().submit(function(e) { alert("this not executed"); $.ajax({ type: "post", url: "script.php", data: $(this).parent().serialize(), success: function(data) { alert(data); } }); e.preventdefault(); });
form parent of select box. first alert executed when change select box option, next 1 never reached. idea why?
this should it. don't bother submit event - not triggered select box.
$('.mycssclass').on('change', function() { $.ajax({ type: "post", url: "script.php", data: $(this).parent().serialize(), success: function(data) { alert(data); } }); });
Comments
Post a Comment