Ajax cross-site call for WCF service

Is it possible to make a cross-site call in Javascript in a WCF service?

I don't mind if it's POST or GET.

But I heard that these days browsers do not allow cross-site calls using POST or GET.

How can I get around this and still call the WCF service?

+3
source share
4 answers

No, you can do this to bypass cross-site browser script blockers. These blockers stop XMLHTTPRequest from accessing any domain, but one that loads the containing script or page.

, : JavaScript DOM, src, URL. RPC "script", JavaScript, , .

POST , URL- src GET, . , WCF GET. , JavaScript, , WCF , JavaScript.

. , test.com , example.com, URL example.com, test.com.

, , , , WCF .

+5

jQuery ? jQuery JSON "JSONP". GET, , ! .

. " getJSON ( JSONP)" : http://docs.jquery.com/Release:jQuery_1.2/Ajax

- JSONP: http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

, !

+4

W3C , Access Control for Cross-Site Requests.

, HTTP- Access Control , .

, , , , , xmlHttpRequests .

. IE8, -, ( ), Firefox 3.1 ( ). , .

2012 .

. , .

, , , , , , , .

+2

To extend Ben's answer ... I expanded our WCF service to support JSONP calls from jQuery using code similar to this example from Microsoft:

http://msdn.microsoft.com/en-us/library/cc716898.aspx

+1
source

Source: https://habr.com/ru/post/1703327/


All Articles