Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18
AJAX IN ASP.
NET MVC 5 PRESENTER: MOHAMMAD ADIL AJAX
• Ajax stands for Asynchronous JavaScript and Xml.
• Is a Web development technique that allows you to make requests to the server in the background using client-side code. • Enables you to update a view without reloading it completely. • Improves the performance of your application and the user experience. AJAX
• Ajax is not a programming language.
• Ajax is a technique used by web developers in order to make websites behave like desktop applications. • Web application using Ajax enables partial page updates, i-e only the related section of the page is updated, without reloading the entire page. PARTIAL PAGES UPDATES AJAX
• AJAX COMPRISES WITH THE HELP OF:
• HTML • CSS • JAVASCRIPT • XML • JSON • PHP AJAX
• There are two types of request send from client to
server. • SYNCHRONOUS REQUEST • ASYNCHRONOUS REQUEST SYNCHRONOUS IN AJAX SYNCHRONOUS IN AJAX
• We have a client- server application, and in that application
we have a button on a form- and let say button event handler takes 10 seconds. • so in a synchronous request when we click the button, request is send to the server and server takes 10 seconds to process that request so while server is processing the request the client is blocked and client waits for the server to complete the process and send request back to the client, at that time the user interface of the client is blocked and we cannot do anything with our interface of website. ASYNCHRONOUS IN AJAX ASYNCHRONOUS COMMUNICATION
• Is the ability of a Web application to send multiple
requests and receive responses from the server simultaneously. • Enables you to work on the application without being affected by the responses received from the server. ASYNCHRONOUS IN AJAX • Ajax applications are non-blocking. as ajax requests are asynchronous, the user doesn’t have to wait for the request processing to complete. • Even while the request is still being processed by the server, the application remains responsive and the user can interact with the application. • When the request processing is complete, the user interface is automatically updated. this is not the case with synchronous request. The user interface is blocked and the user cannot do anything else until the request has completed processing. ASYNCHRONOUS IN AJAX
• Asynchronous means that we are exchanging data to /
from the server in the background without having to refresh the page. AJAX HELPERS ASP.NET MVC application also uses a set of AJAX helpers. • AJAX helpers enable you to create forms and links that point to controller actions. • The only difference is that AJAX helpers behave asynchronously. • While using AJAX helpers, you should not explicitly write JavaScript code make the asynchrony work. • To make use of it, you should ensure that the jquery.unobtrusive- ajax script file is present in the Scripts folder of your application directory. • However, if you want to include the file manually, you need to use the <script> element. UNOBTRUSIVE AJAX
• The ASP.NET MVC Framework provides built-in support for
unobtrusive AJAX. • It enables you to use AJAX helpers to define AJAX features instead of writing code in your views. • To enable unobtrusive AJAX feature in an application, you need to configure the Web.config file. • To enable unobtrusive AJAX feature in the Web.config file, you need to set the UnobtrusiveJavaScriptEnabled property to true under the <appSettings> element of the Web.config. WORKING WITH AJAX • Traditionally, to update the content of a view the full page refresh technique was used. • When the server finishes processing the request, a new page is sent back to the browser. • However, AJAX provides an approach to improve the process of updating views. WORKING WITH AJAX IN MVC 5
• In an ASP.NET MVC application, you can implement
AJAX using
1. AJAX Forms - Ajax.BeginForm()
2. AJAX.ActionLInk() AJAX.BEGINFORM()
• Consider a scenario, where you want to enable a user
to search for product. • When a user types a text to search for a product, the details of the matching products should be retrieved from the server and displayed on the same page, without having to post the page back to the server. • In such scenario, you should use an asynchronous form element on the view. AJAX.ACTIONLINK() • The Ajax.ActionLink() helper method enables you to create an anchor tag with asynchronous behavior. • The first parameter of the Ajax.ActionLink() method specifies the link text. • The second parameter specifies the name of the action method that needs to be invoked asynchronously • The third parameter is for ajax options
(Ebook) ASP.NET AJAX in Action by Alessandro Gallo; David Barkol; Rama Krishna Vavilala ISBN 9781933988146, 1933988142 - The ebook is ready for download to explore the complete content
JavaScript QuickStart Guide: The Simplified Beginner's Guide to Building Interactive Websites and Creating Dynamic Functionality Using Hands-On Projects