Reputation: 1914
I just started learning jquery and I am struggling on some concept problem. If I use load() to update one of the div sections in my website, e.g.:
//link to open another page
$('a#open_page').click(function() {
var myURL = "page.php";
$('#ajaxHandle').load(myURL);
return false;
});
My question is, is everything in page.php going to be loaded literally? If page.php has some headers or php code, are they going to be loaded as well?
Upvotes: 1
Views: 83
Reputation: 165941
Yes, the server will execute any server-side code in that file before returning it to the browser.
Any JavaScript (e.g. in script
elements) will be executed by the browser before the content is inserted into the element (unless you append a selector to the URL, in which case script
elements are stripped out and not executed).
The load
method is simply a shorter way of making a normal AJAX request. By default, it makes a GET request. If you specify data to send to the server, it makes a POST request.
Upvotes: 1
Reputation: 47609
This will fetch the URL from the server and replace the contents of the element with id ajaxHandle
with the result.
What comes back from the request depends on your server. If there is PHP code, and if it executes normally, then you will get the response of the executed PHP. It is just like a normal HTTP request (like the one you used to serve the original page).
Upvotes: 2