I have the following html code:
<div>
<span>Products per page:</span>
<a class="selectview" href="/womens-clothing/shorts?page=1&view=20">20</a>
<a class="selectview" href="/womens-clothing/shorts?page=1&view=200">200</a>
<div>
and the jQuery is as follows:
jQuery('.selectview').click(function (ev) {
ev.preventDefault();
var alink = jQuery(this).attr('href');
var view = getLinkVars(alink)["view"];
var page = jQuery("#currentpageno").val();
alert(alink);
alert(view);
alert(page);
run_ajax(view,page);
});
The code runs fine the first time if I click on any of the links; I see the alerts and the ajax code runs fine, but when I click on it the second time, the whole page is refreshed and no alerts are shown. Then if I click on it again it works, then when I click on it again it works, and so on.
What could I be doing wrong?