javascript - call jquery ajax function on link -


this question has answer here:

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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -