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>

Above File is Load_Method\WebForm1.aspx








WELCOME TO LOAD METHOD OF JQUERY AJAX
Above File is Load_Method\pages\WebForm1.aspx







<h1>THIS IS HEADING 1</h1>
<h2>THIS IS HEADING 2</h2>
<p>This is a paragraph 1</p>
<p id="p2">This is a paragraph 2</p>
Above File is Load_Method\pages\HtmlPage1.html






Comments

Popular posts from this blog

Range Validator Control In ASP.NET Web forms | Form Validation | ASP.NET Web forms

Query String In ASP.NET Web Forms | State Management | ASP.NET | Web Forms

Validation Summary Control In ASP.NET Web forms | Form Validation | ASP.NET