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 () {

                //"load()" method is used 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");


                //"callback()" function will call at the end after "load()" method is completed

                $("#result").load("pages/HtmlPage1.html", function (responseTxt, statusTxt, xhr) {

                    //alert("Load method done..");


                    //alert(responseTxt);

                    //alert(statusTxt);

                    //alert(xhr);


                    if (statusTxt == "success") {

                        alert("All is well");

                    }

                    else

                    {

                        alert("All is not well");

                    }

                });

            });

        });

    </script>

</body>

</html>

ABOVE FILE IS WebForm1.aspx









WELCOME TO LOAD METHOD OF JQUERY AJAX

ABOVE FILE IS TextFile1.txt








<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8" />

    <title></title>

</head>

<body>

    <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>

</body>

</html>

ABOVE FILE IS 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