ASP.NET Podcast Show #128 - AJAX with jQuery - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET AJAX, and now Windows Azure............follow me on twitter at Wally

ASP.NET Podcast Show #128 - AJAX with jQuery

Subscribe to All!

Subscribe to WMV.

Subscribe to M4V (iPod).

Subscribe to MP3.

Download WMV.

Download iPod Video.

Download MP3.

Original Url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2008/12/03/asp-net-podcast-show-128-ajax-with-jquery.aspx

Show Notes:

Source Code:

jQuery Version:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>jQuery Example</title>

</head>

<body>

    <form id="form1" runat="server">

<!--

<script language="javascript" type="text/javascript"

    src="jquery-1.2.6-vsdoc.js"></script>

-->

<script language="javascript" type="text/javascript"

    src="jquery.pack.js"></script>

<div>

<label for="lblOutput">

    Text Out:

</label>

<div id="lblOutput" />

 

<script language="javascript" type="text/javascript">

    $(document).ready(function() {

        $.ajax({

            type: "POST",

            contentType: "application/json; charset=utf-8",

            url: "GetData.asmx/ReturnData",

            data: "{i: 47}",

            dataType: "json",

            success: function(msg) { onSuccess(msg); },

            error: function() {

                alert("An error occurred on the server.");

            }

        });

    });

 

    function onSuccess(msg) {

        var newline = "<br />";

        $('#lblOutput').html("Name: " + msg.d.Name + newline +

                "Notes: " + msg.d.Notes + newline +

                "Passed Value: " + msg.d.PassedValue);

    }

</script>

 

</div>

    </form>

</body>

</html>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

ASP.NET AJAX Version:

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <script type="text/javascript">

   

      function pageLoad() {

          GetData.ReturnData(47, onSuccess);

      }

      function onSuccess(result) {

          var newline = "<br />";

          $get('lblOutput').innerHTML = "Name: " + result.Name +

                newline + "Notes: " + result.Notes + newline +

                "Passed Value: " + result.PassedValue;

 

      }

   

    </script>

</head>

<body>

    <form id="form1" runat="server">

<label for="lblOutput">

    Text Out:

</label>

    <div id="lblOutput" />

 

    <div>

        <asp:ScriptManager

            ID="ScriptManager1" runat="server"

            >

            <Services>

                <asp:ServiceReference

                    Path="~/jQuery/GetData.asmx" />

            </Services>

            </asp:ScriptManager>

    </div>

    </form>

</body>

</html>

Comments

 

Dew Drop - December 3, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - December 3, 2008 | Alvin Ashcraft's Morning Dew

December 3, 2008 9:36 AM

About wallym

Wallace B. (Wally) McClure INETA Speaker's Bureau Microsoft MVP ASPInsider Co-author of "Beginning AJAX with ASP.NET" Co-author of "Professional ADO.NET Programming" Co-author of "Building Highly Scalable Database Applications with .NET" Master's Degree in Electrical Engineering from Georgia Tech Bachelor's Degree in Electrical Engineering from Georgia Tech
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems