jQuery ajax在IE,Chrome和FF中工作……但不是Safari(使用MVC 4的服务器)

我有一个MVC 4应用程序,它接收数据并将Json字符串返回给客户端。 该代码在Chrome,Firefox和IE中完美运行(仅针对8 + ……但我实际上已经看到它在IE7中运行)。 但是,它不适用于Windows上的Safari 5.x(我没有Mac ……所以我无法测试它)。

这是jQuery …(使用1.9.1 … thx Tim B James要求…忘了提前提到它)

$.ajax({ type: 'POST', url: '@Url.Content("~/Request/ValidateApprover/")', data: { 'name': input }, success: function (json) { //do some work here }, error: function () { //tell the user that it failed here } }); 

这是我的控制器被调用…

 [HttpPost] public ActionResult ValidateApprover() { string emailAddress = ""; string name = this.Request.Form["name"]; //<--the form is blank using Safari 5 if (String.IsNullOrEmpty(name) || String.IsNullOrWhiteSpace(name)) return Json(new { result = "blank" }, "application/json", JsonRequestBehavior.AllowGet); //...keep going if you got a value other than blank 

当我尝试使用this.Request.From["name"]在我的Controller中读取结果时,我在使用Firefox,Chrome和IE时很好……但是我使用Safari获得了空白表单值。

编辑1:我写了一个非常简单的PHP页面来检查数据是否在Safari中正确传递。 它似乎是……所以它看起来像IIS和Safari之间的东西是问题。

编辑2:我写了一个非常简单的MVC应用程序进行测试,数据在该测试中遇到….这让我相信它是Safari中的某种HTMLvalidation。 我还删除了此编辑中发布的请求标头数据。

还有其他想法吗?

这是我用的:

function setContent(contentfile){

 if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200 ){ //alert(xmlhttp.responseText); $('#*******').html(xmlhttp.responseText); } } xmlhttp.open("GET",contentfile,true); xmlhttp.send(); 

}

它适用于所有浏览器。

问题在于Safari处理Kerberos身份validation,但我找到了解决方案。

http://forums.iis.net/t/1182376.aspx/1

IIS上的该线程描述了在Safari中不正确地处理Negotiate (即Kerberos )身份validation。 您必须禁用Negotiate作为提供者。

在IIS(我使用IIS 7.5)中,单击您的站点,然后单击Authentication (双击)→ Windows Authentication (单击)→ Providers (在右侧)→ Remove Negotiate and leave NTLM

这解决了Safari的所有问题。

它也适用于我..我使用的是IIS 6.0,我已经完成了。

然后以管理员’命令提示符’运行

cd c:\ inetPub

Cd adminScripts

cscript adsutil.vbs获取w3svc / NTAuthenticationProviders

cscript adsutil.vbs设置w3svc / NTAuthenticationProviders“NTLM”

重启IIS。