Jquery Load
jQuery - AJAX load() Method
jQuery load() Method
The jQuery load() method is a simple, simply powerful AJAX method.The load() method loads information from a server together with puts the returned information into the selected element.
Syntax:
$(selector).load(URL,data,callback);
The required URL parameter specifies the URL you lot wishing to load.The optional information parameter specifies a laid of querystring key/value pairs to mail along amongst the request.
The optional callback parameter is the cite of a component to hold upward executed subsequently the load() method is completed.
Here is the content of our instance file: "demo_test.txt":
<h2>jQuery together with AJAX is FUN!!!</h2>
<p id="p1">This is or together with thus text inwards a paragraph.</p>
The next instance loads the content of the file "demo_test.txt" into a specific <div> element:Example
$("#div1").load("demo_test.txt");
The next instance loads the content of the chemical constituent amongst id="p1", within the file "demo_test.txt", into a specific <div> element:
Example
$("#div1").load("demo_test.txt #p1");
- responseTxt - contains the resulting content if the telephone band succeeds
- statusTxt - contains the condition of the call
- xhr - contains the XMLHttpRequest object
Example
$("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);
});
});
Comments
Post a Comment