how do i specify the element when loading content ajax jquery
Posted
by
phukkie
on Stack Overflow
See other posts from Stack Overflow
or by phukkie
Published on 2012-12-17T09:25:06Z
Indexed on
2012/12/18
5:03 UTC
Read the original article
Hit count: 205
How can I specify an element where the content is to be retrieved from within the pageurl in the code below?
$(function () {
$("a[rel='sort']").click(function (e) {
//e.preventDefault();
/*
if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content;
if commented, html5 nonsupported browers will reload the page to the specified link.
*/
//get the link location that was clicked
pageurl = $(this).attr('href');
//to get the ajax content and display in div with id 'content'
$.ajax({
url: pageurl + '?rel=sort',
success: function (data) {
$('#content1').html(data);
}
});
//to change the browser URL to 'pageurl'
if (pageurl != window.location) {
window.history.pushState({
path: pageurl
}, '', pageurl);
}
return false;
});
});
© Stack Overflow or respective owner