Home > Web Front-end > JS Tutorial > body text

Ajax request WebService cross-domain problem solution

韦小宝
Release: 2017-12-30 19:04:20
Original
1773 people have browsed it

This article mainly introduces the solution to the cross-domain problem of Ajax requesting WebService. This article introduces it to you in great detail and has the value of reference and learning ajax. It is of great value to ajaxInterested friends can refer to the following

1. Background

## Using Ajax in Jquery in asp.net development environment Calling the WebService interface

2. Problems

Cause analysis: The browser has the same origin The impact of the policy (i.e. JavaScript or Cookie can only access content under the same domain);

3. Solution:

(1) JSONP: Only supports GET method

(2) CROS: Cross-domain resource sharing

The following is the CROS solution:

a. Add response header information to the WebService interface:

b. Add relevant configuration section information to the web.config file:

After applying solution a or b, the browser header information changes as follows:

In the end the problem was better solved, but for this Each browser supports different solutions. The attached picture is as follows:


The above is the solution to the cross-domain problem of Ajax requesting WebService introduced by the editor. I hope to be helpful! !

Related recommendations:

Example detailed explanation js combined with json to implement ajax simple example

js cross-domain call WebService A simple example

Detailed example of jQuery ajax calling webservice precautions

The above is the detailed content of Ajax request WebService cross-domain problem solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!