jQuery - Load external content
William McKeehan
William McKeehan
February 3, 2022

jQuery - Load external content

jQuery - Load external content

Do you need to add some external content to a div? It is pretty easy to do with jQuery, as demonstrated in the example below:

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

Source: http://api.jquery.com/load/