Post JSON ajax request with cors not working in IE10/Edge

后端 未结 2 1698
误落风尘
误落风尘 2021-02-07 08:21

Background:- I created a WCF service hosted in my local system IIS. Service exposes GET/POST method and cross domain enabled and can be accessed using https too

2条回答
  •  盖世英雄少女心
    2021-02-07 09:22

    There are a few things you can check client-side:

    • you're trying to override $.support.cors. This is (or was) meant to be a readable property telling you if CORS is supported by the browser. (see jQuery source for where this is checked)
    • Based on jQuery docs for ajax you might want to add xhrFields: { withCredentials: true } to the $.ajax() options
    • Use correct casing of dataType: "json" and charset=UTF-8

    At server-side, you may want to try responding with specific hostname (echo the Origin header) instead of wildcard (*) in the Access-Control-Allow-Origin response header. This is specifically mentioned in MDN in a paragraph also discussing Access-Control-Allow-Credentials:

    Important note: when responding to a credentialed request, server must specify a domain, and cannot use wild carding. The above example would fail if the header was wildcarded as: Access-Control-Allow-Origin: *.

提交回复
热议问题