asp.net - jQuery $.get refreshing page instead of providing data -
i have written code using jquery use ajax data webform, , works fine. i'm copying code project, won't work properly. when class member clicked, give me productid have concatenated onto input id, never alerts data $.get. test page (/products/ajax/default.aspx) have set returns text "testing...". installed web development helper in ie, , shows request getting test page , status 200 correct return text. however, jquery refreshes calling page before ever show me data i'm asking for. below code snippets page. please let me know if there other code blocks need see. thank you!
<script type="text/javascript"> $(document).ready(function() { $(".addtocart_a").click(function() { var sprodidfileid = $(this).attr("id"); var aprodidfileid = sprodidfileid.split("_"); var sprodid = aprodidfileid[5]; // *** alert shows fine -- prodid: 7 alert("prodid: " + sprodid); $.get("/products/ajax/default.aspx", { test: "yes" }, function(data) { // *** alert never gets displayed alert("data loaded: " + data); }, "text"); }); }); </script> <input src="/images/add_to_cart.png" name="ctl00$ctl00$contentplaceholder1$contentplaceholder1$aaddtocart_7" type="image" id="ctl00_ctl00_contentplaceholder1_contentplaceholder1_aaddtocart_7" class="addtocart_a" />
the easiest way tell jquery not return anything.
$(".addtocart_a").click(function(e){ // rest of function return false; });
good luck! if need else let me know.
Comments
Post a Comment