JavaScript cross-domain access is a common problem for web developers, what is Cross-domain, a script loaded on one domain Gets or operates a document property on another domain, and three implementations of JavaScript Cross-domain methods are
One, JavaScript cross-domain access
1. Set the Document.domain value of the access page and the page being visited.
2, use the IFRAME to connect two domains of the page.
II. Ajax cross-domain access
1, using the script tag to achieve
The
Because of security considerations, JavaScript is limited to cross-domain access, but sometimes we want to be able to do some reasonable cross-domain access things, so what to do?
There are two types of situations:
One, access to the page between
Background: Recently encountered new requirements in the development of the company's OA system to migrate a set of small programs to goSome feature information is viewed in applet but the file is uploaded on the PC sideFor example: Leaders in the
As the product continues to evolve, applications need to be deployed to different servers, and when a request is suddenly executed, the browser does not respond, realizing that we also need cross-domain access.Internet search " Crossdomain "can
Yesterday, according to the project team front-end development engineers, in the browser can not directly use AJAX access to the background interface to obtain data, according to his reflection, I consulted the relevant cross-domain solution:One:
1. Web API cross-domain access configuration.Add the following code inside the system.webserver in Web. config:Httpprotocol> customheaders> Addname= "Access-control-allow-origin"value="*" /> Addname= "Access-control-allow-headers"value="*" />
Ajax cross-domain access encounters this exception:XMLHttpRequest cannot loadhttp://10.43.15.23/hnsh/rest/waterinfo/getriverinfo.do. No ' Access-control-allow-origin ' header is present on the requested resource. Origin ' http://localhost:8080 ' is
Recent projects require cross-domain requests for access to data issues. Below through this article to share in C # Ajax cross-domain access code in detail, the need for friends can refer to the following
Recently, because of project needs,
Page A: page B, can you send me a data?Page B: Well, we are not in the same domain because of the web security issue, so the browser prohibits me from transmitting data directly to you.Page A: Is there any way to solve this problem?Page B: You can
1, how do I get Apache to support cross-domain access?Steps:
The corresponding folder in the change httpd.conf,windows is: C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf
Put LoadModule Headers_module modules/mod_headers.so front of the
1, how do I get Apache to support cross-domain access ?Steps:
Modify the corresponding directory in the httpd.conf,windows is: C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf
Remove LoadModule headers_module modules/mod_headers.so in
in this project, we do the full use of JSONP which is a feature of cross-border, complete simple single sign-on authentication and authority control unification. Tao, each has each merit, each has each merit, chooses what way realizes completely
When you request another Web site in an AJAX way, cross-domain request issues occur.XMLHttpRequest cannot load http://google.com/. ' access-control-allow-origin' Http://run.jsbin.io ' is therefore not allowed Access.Compile a server-side servlet
Tool Description: Vs2012,sql server 2008R21. First, build a WCF service project through vs2012 and build it. Open a new vs2012. Build a Web project that accesses services through jquery's AJAX approach.Issue: Because Web projects and WCF services
Wamp Apache Virtual machine configuration multi-domain Access TrilogyWamp:1:c:\windows\system32\drivers\etc->hosts to join your own domain 127.0.0.1www.a.com;127.0.0.1www.b.com2: Locate the installation directory apache2\conf\httpd.conf,
Homologous1, the basic concept: the same-origin strategy is a browser security policy, so-called homology refers to the domain name, protocol, the port is exactly the same.//allow communication under the same domain namehttp//Www.a.com/a.jshttp//Www.
Add these words in the backgroundPrintWriter out = response.getwriter (); Response.setheader ("Access-control-allow-origin", "*/ / set allow all domain access, if just allow a domain name access to replace "*" with the corresponding domain name
To achieve JSONP cross-domain access, you first need to understand what is cross-domain? Then jsonp the relationship with JSON?1. What is cross-domain?Cross-domain is simply a domain name under the program and another domain under the program to do
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.