Computer Magic Logo
Load html content from a file

Friday, January 22, 2016

Published by Aristotelis Pitaridis

We can use the load member function in order to load html contents using a different URLĀ and set them as contents for an element.

$("#ContainerElement").load("FileToLoad.html", function(response, status, xhr) {
    // Error handling
    if(status == "error") {
        $("#ContainerElement").html("An error occured: " + xhr.status + " " + xhr.statusText);
    }
});