Use delegate to debug Ajax applications)

Source: Internet
Author: User

I have been developing Ajax applications recently. As we all know, Ajax is characterized by the separation of the client and the server. The client is usually composed of pure JavaScript and communicates with the server through the XMLHTTPRequest object. When debugging client code, if the server is locally enabled, you can directly edit the client js code on the server by using Samba or other methods. If the server is in a remote location, every time you modify the JS Code, upload it via FTP, and then debug it. Here, we will naturally think of putting JS Code locally. However, XMLHttpRequest can only access URLs under the same domain name, and local JS Code cannot directly use services on remote servers.

Confused, colleagues introduced the DeleGate software, which can be used to debug client code locally.

Delegate is actually a powerful proxy server. It has a mount function similar to Linux, which can map URLs on the Internet to a local machine. By using this function, you can integrate remote servers and local clients into the same domain name for local debugging of client code.

The method is as follows:

Configure Apache to the local port 8080, and then place the client code under htdocs so that it can be accessed through http: // localhost: 8080/client.

Download and decompress the delegate file. Edit the following configuration file delegate. cfg.

-P80
Admin = "yourname@yourmail.com"
Mount = "/client/* http: // localhost: 8080/client /*"
Mount = "/cgi-bin/* http: // server-address/cgi-bin /*"

 

The-P80 In the first line specifies that the delegate uses port 80; the admin in the second line specifies the Administrator email address, which can be set at will; the client in the third line maps to the/client/path of the delegate; the fourth line maps the remote server directory to the/cgi-bin/path of delegate.

In addition, if you need to access the remote server through the proxy server, you can set it as follows:

Mount = "/cgi-bin/* http: // server-address/cgi-bin/*" proxy = "proxy server address: Port"

 

Run the following command on the command line to install delegate. Note that different versions of delegate have different executable file names.
 

 

Dg9.4.1.exe + = delegate. cfg

 

Open your browser and access http: // localhost/client /. In this way, you can see modifications to the JS Code at any time.

In fact, using this method, you can also "steal" services of many websites, that is, develop your own clients, and then forward requests to the server through Delegate. The method is not described in detail.

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.