DOM Traversing
DOM Traversing
AJAX
By:
Parul Madan(AP)
Computer Science
What is Traversing in jQuery?
The load() method loads data from a server and puts the returned data into the
selected element.
Syntax:
$(selector).load(URL , data ,callback);
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("demo.txt", function(responseText, statusTxt, xhr){
if(statusTxt == "success")
alert("External content loaded successfully!");
if(statusTxt == "error")
alert("Error: " + xhr.status + ": " + xhr.statusText);
});
});
});
</script>
<div id="div1"><h2>XXXXXXXXXXXXXXXXXX</h2></div>
$get() and $post()
The $.get() method requests data from the
server with an HTTP GET request.
$.get(URL,callback);
$.post() method requests data from the