Load Method Of jQuery AJAX | jQuery AJAX In ASP.NET Web Forms | Learn ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Load_Method.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btn" value="Click to Get Data"/>
<br/>
<div id="result">
</div>
</div>
</form>
<script src="scripts/JQuery.js"></script>
<script>
$(document).ready(function () {
$("#btn").click(function () {
//We use "load" method only when we want to retrieve text data or html data
/*$("#result").load("pages/TextFile1.txt");*/
//$("#result").load("pages/HtmlPage1.html");
//$("#result").load("pages/HtmlPage1.html h1,h2");
//$("#result").load("pages/HtmlPage1.html p");
//$("#result").load("pages/HtmlPage1.html #p2");
//When "load" method will finish its working after that alert() function will call
//$("#result").load("pages/HtmlPage1.html", function () {
// alert("Load Method Done..");
//});
$("#result").load("pages/HtmlPage1.html", function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success")
{
alert("All is well");
}
else
{
alert("All is not well");
}
//alert(responseTxt);
//alert(statusTxt);
//alert(xhr);
});
});
});
</script>
</body>
</html>
Comments
Post a Comment