Node. js + Ajax: Get the data returned by the HTTP server _ node. js

Source: Internet
Author: User
Tags node server
This article mainly introduces node. js + Ajax is used to obtain the data returned by the HTTP server. The explanation is very detailed and many examples are provided. It is a very good article. We recommend it to you here. Let's take a look at the sample code for retrieving HTTP server response data through AJAX requests on an HTML5 page. because we set the server port to 1337 and run the HTML5 page from the website with port 80, this is a cross-origin operation. We need to add the Access_Control_Allow_Origin field in the HTTP response header, specify the parameter as the domain name + port number that allows data requests from the server (when the port number is omitted, any port under the domain name is allowed to request data from the server ),

Static Page: index.html (Note: It must be placed in the server environment. If it is a Windows 7 system, you can enable the IIS service and run the page directly ,)

The Code is as follows:






Node ajax request (html5 page)

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.