【问题标题】:Jquery ajax Post + cross domain [duplicate]Jquery ajax Post +跨​​域[重复]
【发布时间】:2012-06-05 21:34:27
【问题描述】:

可能重复:
Access Control Allow Origin not allowed by

我在尝试使用 jquery 发帖时遇到问题:

             function SetUserAnswer(reponse) {
    $.ajax({
        type: "POST",
        url: "@SettingManager.GetValue("WS_Sondage_Adress").Value" + "SetUserAnswer",
        data: JSON.stringify({ deviceId: $("#Guid").attr("value"),
            pollId:  $("#PollId").attr("value"),
            answerId: reponse,
            parameters: ""
        }),
       dataType: "json",
       crossDomain: true,
      contentType: "application/json; charset=utf-8"
    }).done(function () {
        alert("OK !");
    }).fail(function () {
        alert("KO :(");
    });

}

但 Firefox 发送“选项”而不是“发布”

OPTIONS SetUserAnswer

405 Method Not Allowed

22.1.68.146:8080

1.7 KB

10.70.134.7:8080


80ms
En-têtesRéponseHTML
Réponsevoir le code source
Access-Control-Allow-Orig...    *
Age 0
Allow   POST
Cache-Control   private
Connection  Keep-Alive
Content-Length  1732
Content-Type    text/html; charset=UTF-8
Date    Thu, 31 May 2012 15:28:21 GMT
Proxy-Connection    Keep-Alive
Server  Microsoft-IIS/7.0
X-AspNet-Version    4.0.30319
X-Powered-By    ASP.NET
Requêtevoir le code source
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language fr,en-us;q=0.8,fr-fr;q=0.5,en;q=0.3
Access-Control-Request-He...    content-type
Access-Control-Request-Me...    POST
Cache-Control   no-cache
Host    22.1.68.146:8080
Origin  nom_machine
Pragma  no-cache
Proxy-Connection    keep-alive
User-Agent  Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0

我在做跨域发帖时只有这个问题?

【问题讨论】:

标签: c# javascript jquery post cross-browser


【解决方案1】:

也将数据类型从 json 更改为 jsonp,我在您的回复中看不到后续标题

Access-Control-Allow-Origin *

【讨论】:

  • 如果他使用的是JSONP,响应需要支持CORS吗?
猜你喜欢
  • 1970-01-01
  • 2015-02-03
  • 2012-04-14
  • 2012-05-18
  • 2011-03-31
  • 2013-06-04
  • 2015-10-06
  • 2013-01-05
相关资源
最近更新 更多