InApp   /   Our Leaders   /  

Calling Cross Domain WCF Service using Jquery

Calling Cross Domain WCF Service using Jquery

There is no guarantee that the WCF services and client application will be hosted under same domain. When you try to call cross domain WCF service hosted in different domain using client script, it behaves differently on different browsers.

When you want to perform “POST” or “GET” request on cross domain WCF service or normal service using jquery/javascript or ajax, the browser actually sends an “OPTIONS” verb call to your WCF service that is not mention in your WCF method attribute. We mention there “POST” or “GET” to call a WCF service method and hence get error to call cross domain WCF service.In this case the client request headers method type is “OPTION” not “POST” and the response headers has content-type “text/html; charset=UTF-8” instead of “json;charset=UTF-8”.

To change these options we need to do some changes in web.config of hosted WCF service.