Implementing Advanced Ajax in A Web Application
Implementing Advanced Ajax in A Web Application
Implementing Advanced Ajax in A Web Application
Implementing Advanced
Ajax in a Web Application
Module Overview
• Implementing Ajax in ASP.NET MVC Pages Using Microsoft
Ajax
• Implementing Ajax in ASP.NET MVC Pages Using jQuery
jQuery.load method
jQuery.get method
jQuery.post method
jQuery.ajax method
jQuery.load Method
• This method calls the server and loads the HTML into an
area of the page.
$('#result').load('ajax/test.html #container');
$.get("server/test ",
{ employeeId: 123, name: "John" },
function(data){
alert("Data Loaded: " + data);
}
);
jQuery.post Method
• The POST verb is typically used to indicate that the
request is changing data on the server
• POST requests are never cached, unlike GET requests
$.post("/server/test ",
{ some: ‘data’, for: ‘the request’},
function(data){
alert("Data Loaded: " + data);
}
);
jQuery.ajax Method
• Low level method used by all other Ajax methods in
jQuery.
• Takes a hash of parameters.
• url, type, data, and success are the most commonly used
parameters.
• The error parameter can also be used to create a custom
error handler.
Lesson 3: Working with jQuery and Ajax Events
• jQuery.ajaxSend Event Handler
.ajaxSend
.ajaxComplete
.ajaxError
Lab: Implementing Advanced Ajax for the
AdventureWorks Web Application
• Exercise 1: Using Microsoft Ajax in an MVC Page
Logon information
Virtual machine 10264A-GEN-DEV
User name Student
Password Pa$$w0rd
• Best Practices
• Tools