I have a problem with jQuery ajax. I have javascript
<script type="text/javascript">
$(function() {
$('body').on("click", "#pager a", function(e) {
e.stopPropagation();
e.preventDefault();
var a = $(this);
var model = $('#searchForm').serialize();
$.ajax({
url: '/Product/Products',
type: 'POST',
data: {
model: model, page: a
},
success: function (data) {
alert('success');
$('#productsList').html(data);
}
});
});
});
</script>
This code produce error "Uncaught RangeError: Maximum call stack size exceeded" and I don't understand why. I have no trigger, I used preventDefault and stopPropagation, but I still have this error. Can anyone help me?
page: aas part of the data you are submitting, whereais a jQuery object - what do you expect that to do? - nnnnnn<a>'s are on the page (nested within#pager, that is)? Post your html.#pagersounds like a pagination of sorts. If you, for example, have thousands of pages in your pagination display (Eg. ?page=1, ?page=2, 50, 100, 1000), all referenced with<div id="#pager"><a href="?page=2">...<a href="?page=10000"></div>, then binding the click handler on ~x<a>elements could easily fill the stack. - mferly