Ajax,ajaxpro description

Source: Internet
Author: User
1, what is Ajax

Ajax is an English abbreviation for asynchronous JavaScript and XML (asynchronous JavaScript and XML). The inventor of the term "Ajax" is Jesse James Garrett, and Google is the one that has aggressively promoted and made Ajax technology hot. The core idea of Ajax is to send asynchronous requests using the XMLHttpRequest object. 2, why use Ajax to reduce the burden on the server. The principle of Ajax is "on-demand data", the maximum program to reduce redundant requests, reduce the burden on the server. No need to refresh the page, reduce the user's psychological and actual waiting time. In particular, when reading a large amount of data, will not be like refreshing the page as the case of white screen, Ajax use the XMLHttpRequest object to send the request and get the server response, without reload the entire page, with JavaScript Operation Dom Update the page. Therefore, in the process of reading the data, the user is faced with is not a white screen, is the original page content (also can add a "loading" hint box to let users know that the data is currently being read), only after the data received to update the corresponding part of the community content. This update is instantaneous and is almost impossible for the user to feel. Bring a better user experience can put some of the previous server burden of work to the client, using the client idle ability to deal with, reduce the server burden, make full use of bandwidth resources, save space and broadband rental costs. You can call external data based on standardized and widely supported technologies that do not require downloading plug-ins or small programs. Further promote the separation of page rendering and data 3, AJAX application Scenarios

Scenario 1: Data validation

Scenario 2: Fetching data on demand

Scenario 3: Automatic Update page 4, AJAX development Framework JQuery EXT YUI qooxdoo DWR (Direct Web Remoting)

The product is currently being added to the webwork, open Source (Apache). You can call the application framework of Java methods directly in JavaScript code, and you can transfer request calls in JavaScript to Java methods and return execution results to JavaScript. Ajaxpro

Ajaxpro is the first free library to support a variety of ways to access server. NET via JavaScript, similar to Sajax. It can send JavaScript requests to the. Net method, and the service side is passed back to JavaScript, even the serialized custom class. The main features are as follows:

Session and application data can be accessed in JavaScript;

Cached Query Results

Free use of source code

All classes support JavaScript client return data, can use dataset in JavaScript

Accessing and returning data using the HtmlControls component

The page does not need to be overloaded with event proxies (data access layer)

Because only one call interface method is provided, the server-side CPU takes up very little. Magicajax

Magicajax integrates AJAX functionality into the page in the simplest way, without the need to modify the ASP.net control, to write new controls, or to write JavaScript, which has the following characteristics:

The application configuration is simple and easy to use;

Use only one ajaxpanel to achieve AJAX functions, as long as the need for brushless control into the Ajaxpanel can be.

Ajax features and ordinary postback can coexist in a webform,magicajax processing module that handles only callback actions for controls contained in Ajaxpanel.

The content of ViewState is visible to postback and callback, therefore, whether it is viewstate produced by callback or postback, it is visible;

Provides a callback event model similar to the postback

Support IE and Firefox anthem.net

Compared with the traditional Ajax technology, Anthem.net has the following advantages:

Without any technical upgrades, people who previously did not use AJAX technology could have asynchronous interactions in the way they had done before;

Support asp.net 1.1 and asp.net 2.0 5, Ajaxpro description

This document uses the Ajaxpro.net framework to implement AJAX functionality: Calling the server-side method asynchronously at the client. Ajaxpro.net is an excellent. NET Environment Ajax framework, the use is very simple, you can access the relevant information, this document with a simple example of the use of Ajaxpro several key points, this example to achieve a simple function, The server side returns the result of the number entered in the page plus 1 to the client (note that there must be a Ajaxpro package, that is, a AjaxPro.dll file, which can be downloaded from VSS). 6, Ajaxpro case Description 6.1, add AjaxPro.dll application

2.1.1 Opens the project with VS, in its Explorer, right-click the reference, and left-click Add Reference, as shown in Figure 1_1

Figure 1-1

2.1.2 appears as shown in Figure 1_2 dialog box, click Browse, find the AjaxPro.dll file location, double-click AjaxPro.dll, and then click OK.

Figure 1-2

2.1.3 in the Resource Manager's Reference folder, you can see the Ajaxpro, which indicates the success of the Add reference, as shown in Figure 1_3.

Figure 1-3 2.2, configuring Web.config

The role of this step is to ensure that the client requests to "AJAXPRO/*.ASHX" (post and get) are ajaxpro.ajaxhandlerfactory intercepted.

Open the Web.config file and add the following code after <configuration><system.web>.

<add verb= "Post,get" path= "Ajaxpro/*.ashx" type= "ajaxpro.ajaxhandlerfactory, Ajaxpro"/>

As shown in Figure 2_1.

Figure 2-1

2.3, add the service-side method

2.3.1 Open the background code, add the following code in the Page_Load method body,

AjaxPro.Utility.RegisterTypeForAjax (typeof (class name of the Class));

As shown in Figure 3-1.

Figure 3-1

The effect is to output the following code to the client:

<script type= "Text/javascript" src= "/ch33/ajaxpro/core.ashx" ></script>

<script type= "Text/javascript" src= "/ch33/ajaxpro/ch33". Verify,ch33.ashx "></script>

2.3.2, add a number plus one method, first add [Ajaxpro.ajaxmethod] before the method, and then write the method like the C # method, as shown in Figure 3-2

Figure 3-2

Note: The [Ajax.ajaxmethod] identity needs to be added so that the client can access 2.4, add foreground code

Add the JS script in the foreground, invoke the server-side method, as shown in Figure 4-1 (TRY.AJAXTEST.ADD (num), try for the page class, that is, the namespace where the Ajaxtest class is located, this is a try, and Ajaxtest is the class name, Add is the method name)

Figure 4-1

2.5, run the program, test results

You can achieve the desired effect by following the four steps above, as shown in Figure 5-1.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.