An easy way to get data across domains by Ajax __ajax

Source: Internet
Author: User

The restrictions on cross-domain communication are on the browser side, which is the client, so you can make a fuss from server-side code. This is the same as the last few days gzip, the problem is very similar to the gzip stream on the server because the ISA blocked to download compressed files, and finally wrote a compression agent placed on the server, forcing the return of compressed data.

The easiest way to do this is to write an agent to forward the data from another domain to the domain, and then use JS to access the agent.

such as code: Obj.sendrequest ("http://www.abc.com/test.aspx?p1=tt&p2=sss");

will become Obj.sendrequest ("redirect.aspx?url=http%3a%5c%5cwww.abc.com%5ctest.aspx%3fp1%3dtt%26p2%3dsss

Where redirect.aspx is forwarding agent, considering that some parameters of obj object may be post, should be on this proxy page server side to pass all request parameters to the requesting page, the following example omits this step. The code for the forwarding agent for ASPX is simple system..net.webclient wb = new System.Net.WebClient ();
byte [] b = wb. Downloaddata (request["URL"]);
Response.BinaryWrite (b);

This is actually more convenient than the server side is using XMLHHTP.

Btw:ie limits the Cross-domain place in the

Tools-internet Options-security-Custom level-access data source through domain-disabled

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.