Goahead using Ajax for local refreshes

Source: Internet
Author: User
ajax===http://blog.csdn.net/seuge/article/details/8209685

"Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML)

When we operate the page, we often just need to refresh a portion of the data on the page or even a text box data, but the traditional way of refreshing the server will send the entire page back to the browser, the browser load the entire page, so not only wasted bandwidth, and the entire page refresh is not smooth.

Ajax technology solves this problem, the idea of Ajax is that I need to refresh the local data when a request to the server, the server receives the request data will need to refresh the data loopback, the browser after receiving the data through the script to update the corresponding location of data, the process must be in the background. The core of this process is the JavaScript object XMLHttpRequest. The object is a technique that supports asynchronous requests. In short, XMLHttpRequest allows you to use JavaScript to make requests to the server and handle the response without blocking the user.
implementation in Goahead:

1. First is a front page:

[HTML] View plain copy

2. Implement the XMLHttpRequest request response on the server side.

Create a handle//and ASP or form for the AJAX request, adding an AJAX handler function to the. c file.

[HTML] view plain copy int websajaxhandler (webs_t wp, char_t *urlprefix, char_t *webdir, int arg, char_t *url,       char_t *path, char_t *query) {websheader (WP);       Webswrite (WP, T ("<body>

[HTML] view plain copy websurlhandlerdefine (T ("/ajax"), null, 0,  WEBSAJAXHANDLER,&NBSP;0);   This enables a partial refresh.
extension [HTML] view plain copy xmlhttp.open ("GET", "/ajax/", True);   Xmlhttp.send ();  
This is a background data request, now only a schematic, so there is no classification of AJAX requests, can be subdivided later such as
Xmlhttp.open ("GET", "/ajax/time", true); The
then responds with two judgements on the Goahead side, responding to the response.
#################################################
Above is a particularly good framework for
more detailed explanations see: http://www.w3school.com.cn/ Ajax/index.asp

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.