简体   繁体   中英

about the concept of jQuery load()

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, eg:

   //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?

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).

Yes, the server will execute any server-side code in that file before returning it to the browser.

Any JavaScript (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM