javascript - call jquery ajax function on link -
this question has answer here:
- jquery ajax method not passing variables 3 answers
i calling function click on link. successful call can not fix response of function div
the problem getting result through function , shows me result gone in 2 seconds because page refreshes. how possible set response on page refresh?
<a href="screen.php?{$a}&itemid={$itemarray[sec].itemid}" class="btn itemid" id="{$itemarray[sec].itemid}" name="itemid" onclick="getqty(this.id);">{$itemarray[sec].itemnm}</a> function
function getqty(itemid) { var datastring = "itemid=" + itemid; $.ajax({ type:"get", url:"allqty.php", data: datastring, success:function(data) { $('.totalqty').html(data) } }); } here div fix response of function
<div class="totalqty"></div>
here have added onclick function ajax reponse didn't prevent default action of link i.e. href attribute. add event.preventdefault(); function prevent redirecting on anchor tag click
Comments
Post a Comment