I followed Uncle Cheese's Ajax tutorial which I have working with some links that query a different page and url.
What I want to do now is add the Ajax queries to a drop down list instead. So when a value is selected from the drop down it will go to initiate the request.
Is there a way to get this working?
if ($('.pagination').length) {
var paginate = function (url) {
var param = '&ajax=1',
ajaxUrl = (url.indexOf(param) === -1) ?
url + '&ajax=1' :
url,
cleanUrl = url.replace(new RegExp(param+'$'),'');
$.ajax(ajaxUrl)
.done(function (response) {
$('.main').html(response);
$('html, body').animate({
scrollTop: $('.main').offset().top
});
window.history.pushState(
{url: cleanUrl},
document.title,
cleanUrl
);
})
.fail (function (xhr) {
alert('Error: ' + xhr.responseText);
});
};