ajax by asp.net development company in india

14
iFour Consultancy AJAX

Upload: ifour-institute-sustainable-learning

Post on 21-Feb-2017

45 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Ajax by asp.net  development company in india

iFour Consultancy

AJAX

Page 2: Ajax by asp.net  development company in india

Introduction to AJAXWhy use AJAXJQuery AJAXLoading Simple DataGetting JSON DataJQuery AJAX MethodJQuery AJAX Events

INDEX

http://www.ifourtechnolab.com/

Page 3: Ajax by asp.net  development company in india

What is Ajax?

An Asynchronous JavaScript and XML Technique for creating fast and dynamic web pages It allows web pages to be updated asynchronously by exchanging small amounts of data

with the server behind the scenes This means that it is possible to update parts of a web page without reloading the whole

page Classic web pages, (which do not use AJAX) must reload the entire page if the content

should change Examples of applications using AJAX: Google Maps, Gmail, YouTube, and Facebook

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 4: Ajax by asp.net  development company in india

Why use Ajax?

Client/Server Apps: Dynamic data Static forms, controls, code, etc Efficient, but not flexible

Traditional Web Apps: Dynamic data Dynamic forms, controls, code, etc Flexible, but inefficient, and noticeably slow

Ajax Apps: Dynamic data Static or dynamic forms, controls, code, etc Best of both worlds

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 5: Ajax by asp.net  development company in india

Why use Ajax?

Multithreaded data retrieval from Web serversPre-fetch data before neededProgress indicatorsAppearance of speedAvoids need for setTimeout()

Less bandwidth required; less server loadReload partial page, not entire pageLoad data only, not even partial page

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 6: Ajax by asp.net  development company in india

JQuery is a great javascript tool which provides a rich set of AJAX methods to develop next generation web application

All jQuery AJAX methods use the ajax() method, this method is mostly used for requests where the other methods cannot be usedSyntax :• $.ajax({name:value, name:value, ... })• The parameters specifies one or more name/value pairs for the AJAX request

Possible names/values in the table below:• async : A Boolean value indicating whether the request should be handled asynchronous or

not. Default is true• beforeSend() : A function to run before the request is sent

jQuery AJAX

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 7: Ajax by asp.net  development company in india

cache : A Boolean value indicating whether the browser should cache the requested pages. Default is true

contentType : The content type used when sending data to the server context : Specifies the "this" value for all AJAX related callback functions data : Specifies data to be sent to the server dataType : The data type expected of the server response complete(status) : A function to run when the request is finished (after success and error functions) error(status,error) : A function to run if the request fails success(result,status) : A function to be run when the request succeeds url : Specifies the URL to send the request to. Default is the current page type : Specifies the type of request. (GET or POST)

jQuery AJAX

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 8: Ajax by asp.net  development company in india

Here is the simple syntax for load() method [selector].load( URL , [data] , [callback] );URL : The URL of the server-side resource to which the request is sentdata : Represents an object whose properties are serialized into properly encoded parameters to

be passed to the request. If specified, the request is made using the POST method. If omitted, the GET method is used

callback : This function invoked after the response data has been loaded into the elements of the matched set The first parameter passed to this function is the response text received from the server and second

parameter is the status code

Loading Simple Data[selector].load( URL, [data], [callback] );

[selector].load( URL, [data], [callback] );

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 9: Ajax by asp.net  development company in india

Here is the simple syntax for getJSON() method [selector].getJSON( URL , [data] , [callback] );URL : The URL of the server-side resource contacted via the GET methoddata : An object whose properties serve as the name/value pairs used to construct a query string

to be appended to the URL, or a preformatted and encoded query stringcallback : A function invoked when the request completes. The data value resulting from

digesting the response body as a JSON string is passed as the first parameter to this callback, and the status as the second

Getting JSON data

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 10: Ajax by asp.net  development company in india

Following are all important JQuery AJAX methods for programming• jQuery.ajax(options) : Load a remote page using an HTTP request.• jQuery.ajaxSetup(options) : Setup global settings for AJAX requests.• jQuery.get( url, [data], [callback], [type] ) : Load a remote page using an HTTP GET request.• jQuery.post( url, [data], [callback], [type] ) : Load a remote page using an HTTP POST request.• jQuery.getJSON( url, [data], [callback] ) : Load JSON data using an HTTP GET request.• jQuery.getScript( url, [callback] ) : Loads and executes a JavaScript file using an HTTP GET

request.

jQuery AJAX Methods

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 11: Ajax by asp.net  development company in india

• load( url, [data], [callback] ) : Load HTML from a remote file and inject it into the DOM• serialize( ) : Serializes a set of input elements into a string of data• serializeArray( ) : Serializes all forms and form elements like the .serialize() method but

returns a JSON data structure

jQuery AJAX Methods

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 12: Ajax by asp.net  development company in india

You can call various JQuery methods during the life cycle of AJAX call progress. Based on different events/stages following methods are available• ajaxComplete( callback ) : Attach a function to be executed whenever an AJAX request completes• ajaxStart( callback ) : Attach a function to be executed whenever an AJAX request begins and

there is none already active• ajaxError( callback ) : Attach a function to be executed whenever an AJAX request fails• ajaxSend( callback ) : Attach a function to be executed before an AJAX request is sent• ajaxStop( callback ) : Attach a function to be executed whenever all AJAX requests have ended• ajaxSuccess( callback ) : Attach a function to be executed whenever an AJAX request completes

successfully

jQuery AJAX Events

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 13: Ajax by asp.net  development company in india

http://www.w3schools.com/jquery/jquery_ref_ajax.asp http://api.jquery.com/jquery.ajax/ http://www.tutorialspoint.com/ajax/

References

C# Software Development Companies India http://www.ifourtechnolab.com/

Page 14: Ajax by asp.net  development company in india

Questions?

C# Software Development Companies India http://www.ifourtechnolab.com/