O'Reilly logo

ASP.NET 4 24-Hour Trainer by Toi B. Wright

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 25A. Using jQuery for Ajax in Web Forms

In Lesson 23 you learned about using JavaScript to perform client-side programming. In that lesson you were introduced to the jQuery script library. In Lesson 24A you learned how to use the AJAX Extensions provided by the ASP.NET Web Forms framework. In this lesson I teach you how to use the Ajax tools provided by jQuery.

AJAX METHODS

These are the Ajax methods that jQuery provides:

  • $.ajax — This method performs an Ajax request. All of the other methods in this list are shortcuts that use this method.

  • $.get — This method loads HTML using an HTTP GET request.

  • $.getJSON — This method loads JSON-encoded data using an HTTP GET request.

  • $.getScript — This method loads a JavaScript file using an HTTP GET request and executes it.

  • .load — This method loads HTML into the specified element.

  • $.post — This method loads HTML using an HTTP POST request.

    Note

    JSON stands for JavaScript Object Notation. It is a format used to represent simple data structures and objects in a lightweight, text-based, human-readable format.

The simplest way to fetch data asynchronously from the server is to use the .load method. The .load method can be used to replace the UpdatePanel server control that was introduced in Lesson 24A. These are the parameters of the .load method:

  • url — This is a string that contains the URL to which the request is sent. This is the only required parameter.

  • data — This is a string that contains any data that needs to be sent to the URL.

  • complete — This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required