javascript - jQuery update record only once unless I refresh the page -
i using jquery
update database record
. updates fine first time, never update record again unless page reloaded.
i using jquery
because don't want refresh page. code shown below. please how can amend code allow user update record many times wants?
$('body').on('click', '#subform', function() { $.post($("#form_id").attr("action"), $("#form_id").serialize(), function(info) { $("#result").html(info); }); clearinput(); $("html, body").animate({ scrolltop: 0 }, "slow"); }); $('body').on('submit', '#form_id', function(event) { event.preventdefault(); return false; }); function clearinput() { $("#form_id")[0].reset(); }
<div id="result"></div> <form action="upgrade.php" method="post" id="form_id"> <select name="item"> <option><?php echo $item;?></option> <?php /* php script */ ?> </select> <select name="category"> <option><?php echo $category;?></option> <?php /* php script */ ?> </select> <button id="subform">save</button> </form>
Comments
Post a Comment