Is there a simple way to get the parameters at the end of an href attribute of a clicked link using the click event object?
I have some 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>
What I'm trying to do is paginate the results of a search that I've done with ajax. The search runs fine and a get a list of users that match the query. The part of the results script that creates the pagination links is also working.
In the example above, there are two pages of results. What I want to do when a user clicks the link to go to page 2 of the results is to intercept the link click and instead create a new ajax request using term=ma&p=2
as the data passed to the request.
So, long story short, is there an easy way to get term=ma&p=2
from the event object passed the the anonymous function in my jQuery above?