javascript - Form submit using jquery & passing values -
i want accomplish following using jquery:
frm_rooms.action="create_rooms.php?action=save"; frm_rooms.submit(); i tried following jquery doesn't work:
$('#frm_rooms').submit(function(event) <br/>{ $.post("create_rooms.php", { action: "save" } ); });
do this:
$('#frm_rooms').submit(function(event){ $.post("create_rooms.php", {action: "save" }, function(){ alert("data saved"); }); return false; //this vital }); if want parameters passed in query string (get method) use $.get instead of $.post.
edit: thinking better, if have fields inside form want submitted, should do:
$('#frm_rooms').submit(function(event){ $.post("create_rooms.php?action=save", $(this).serialize(), function(){ alert("data saved"); }); return false; //this vital }); hope helps. cheers
Comments
Post a Comment