jasmeet Posted April 18, 2014 Share Posted April 18, 2014 <script> $('.add_to').click(function(){ //alert(1); productId= $(this).attr('id'); //var grandTotal= $('#grandTotal').html(''); $('#sucessAdd').html('<img src="images/ajax-loader.gif" align="center" />'); //var grandTotalfloat= parseFloat(grandTotal); $.ajax({ type: "POST", url:"pass.php", data: {action:'addCatalog',productId:productId}, success:function(result){ //alert(result) if(result==1){//add_to_cat $('#'+productId).remove(); $('#'+productId).fadeTo("fast", .5); $('#sucessAdd').html(''); //$('#sucessAdd').css('color','green'); $('#sucessAdd').addClass('add-sucess'); $('#sucessAdd_'+productId).html('<font coloe="red"><b>Add Successfully</b></font>'); $("#"+productId).style.display="block"; } } }) }); </script> <div class="items_box_link"> <a href="#" id="<?php echo $productRow['id'];?>" class="add_to">ADD TO CART</a> </div> ..........................................////////////////////////////............................................ after add to cart, my page goes to top but i want it to remain dere only.. any help!.. thanks. Quote Link to comment Share on other sites More sharing options...
denno020 Posted April 18, 2014 Share Posted April 18, 2014 add preventDefault() into the mix. $("").click(function(e){ e.preventDefault(); }); I'm pretty sure that does it. Quote Link to comment Share on other sites More sharing options...
jasmeet Posted April 19, 2014 Author Share Posted April 19, 2014 add preventDefault() into the mix. $("").click(function(e){ e.preventDefault(); }); I'm pretty sure that does it. not working. !! Quote Link to comment Share on other sites More sharing options...
denno020 Posted April 19, 2014 Share Posted April 19, 2014 Firstly, exclamation points on the Internet makes it seem like you're shouting, which in turn makes you sound ungrateful for any help I was trying to offer, even if it didn't help. Can you post the code that you have now. Quote Link to comment Share on other sites More sharing options...
Strider64 Posted April 19, 2014 Share Posted April 19, 2014 (edited) I'm only guessing but it might simple be fixed by doing this Change this <a href="#" id="<?php echo $productRow['id'];?>" class="add_to">ADD TO CART</a> to: <a href="" id="<?php echo $productRow['id'];?>" class="add_to">ADD TO CART</a> I think the href="#" is causing the page to go to the top or you can disable it in script (which probably is the better of the two options and probably won't cause any problems) : I'm assuming you're using jQuery: $(".add_to").on('click', function(e){ e.preventDefault(); $(this).removeAttr( "href" ); }); Edited April 19, 2014 by Strider64 Quote Link to comment Share on other sites More sharing options...
Strider64 Posted April 19, 2014 Share Posted April 19, 2014 I just wanted to add, you already have the $('.add_to) in your script, just add the inner part of the code to the script. Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 19, 2014 Share Posted April 19, 2014 (edited) I would like to suggest: Was: }) }); </script> Now: }) } return false; ); </script> Edited April 19, 2014 by bsmither Quote Link to comment Share on other sites More sharing options...
jasmeet Posted September 15, 2014 Author Share Posted September 15, 2014 Firstly, exclamation points on the Internet makes it seem like you're shouting, which in turn makes you sound ungrateful for any help I was trying to offer, even if it didn't help. Can you post the code that you have now. sorry. Quote Link to comment Share on other sites More sharing options...
jasmeet Posted September 15, 2014 Author Share Posted September 15, 2014 thankyou everyone for helping me with the script. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.