Reputation: 3924
How can you reload ONLY a div or element using jQuery AJAX?
Meaning, we have a div currently on our page and we only want to reload THAT one div.
We tried
$('#mydiv').load("/currentpage", "#mydiv");
But this just reloads the whole pages' content into that div. No idea why.
So we thought maybe the .ajax() would work. But we don't quite know how.
Any help is appreciated.
Upvotes: 0
Views: 643
Reputation: 171669
Your syntax is incorrect. The page fragment(s) is/are part of the url string and separated by space
$('#mydiv').load("/currentpage #mydiv");
See section Loading page fragments in load() API Docs
Upvotes: 1