Answer the question
In order to leave comments, you need to log in
Ajax and PHP - why does the whole page load instead of a specific block?
I'm building a website right now and I'm having a problem.
Using Ajax, you need to pull one of the blocks with a unique id on the page from a specific (static) php page.
$('.link_to_main').click(function() {
$('#page_content').load("my_file.php #my_container");
});
Answer the question
In order to leave comments, you need to log in
I usually do something like this.
$.ajax({
url: "my_file.php",
success: function (response) {
$('#page_content').html( $(response).filter('#my_container').html() );
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question