Is there an easy way to get the parameters at the end of the href attribute of a clicked link using a click event object?
I have jQuery code that looks like this:
$(document).ready(function() { $('#pages').delegate("a", "click", function(e) { var formData = "parameters to clicked link"; $.ajax({ url: 'friends2.php', dataType: 'json', data: formData, success: function(data) { $('#searchbutton').attr("disabled", false); $('#searchresults').html(data.results); $('#pages').html(data.paginate); } });//ajax end return false; }); });
And here is the relevant HTML:
<div id="pages"> <span class="disabled">previous</span> <span class="current">1</span> <a href="friends.php?term=ma&p=2">2</a> </div>
I am trying to paginate the search results that I did with ajax. The search runs fine and gets a list of users matching the query. The result part of the script that creates the page links also works.
In the above example, there are two pages of results. What I want to do when the user clicks the link to go to page 2 of the results is to intercept the link and instead create a new ajax request using term=ma&p=2 as the data passed to the request.
So, a long story, is there an easy way to get term=ma&p=2 from an event object that passed an anonymous function in my jQuery above?
javascript jquery ajax
itsmequinn
source share