// Used like this: $(selector).load(URL,data,callback); //e.g. use case: <div id="example"> <!-- Load data here --> </div> <script> $("#example").load("sum.php", { "num1": 1, "num2": 2 }, function () { DoSomething(); }); </script> // sum.php echo $_POST['num1'] + $_POST['num2']; // Output: 3
$("button").click(function(){ $("#div1").load("demo_test.txt", function(responseTxt, statusTxt, xhr){ if(statusTxt == "success") alert("External content loaded successfully!"); if(statusTxt == "error") alert("Error: " + xhr.status + ": " + xhr.statusText); }); });