在暂存时,在错误回调中,jqXHR.responseText作为html字符串返回,但在本地它完美地运行&在同一个错误回调中返回一个json对象,我正在使用JQuery进行典型的异步HTTP(Ajax)请求。
错误回调的片段如下所示
error: function (jqXHR, textStatus, errorThrown) {
l.stop();
l.setProgress(0);
$("#error").show();
try {
var data = $.parseJSON(jqXHR.responseText);
if (data && data.Message && data.Message.length > 0) {
$("#error .message").html(data.Message);
} else {
$("#error .message").html("An unexpected error has occurred. Please contact support for assistance.");
}
} catch (ex) {
$("#error .message").html("An unexpected error has occurred. Please contact support for assistance.");
}
}
在登台时返回的jqXHR.responseText如下所示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header">
<h1>Server Error</h1>
</div>
<div id="content">
<div class="content-container">
<fieldset>
<h2>500 - Internal server error.</h2>
<h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
</fieldset>
</div>
</div>
</body>
</html>
下面给出的是当我在本地运行时的图像,你可以看到json对象被返回
而且,这是在登台时发生的事情
登台时的IIS版本为7.5.7600.16385,JQuery版本为2.1.4
有人可以告诉我可能出现的问题或我应该从哪里开始寻找解决此问题的方法。
下面&#39; ajax调用的完整代码
$.ajax({
type: 'POST',
url: '@Url.Action("UpdateAdjustment", "AccredScoring")',
dataType : "json",
data: $(this).serialize(),
success: function (data, textStatus, request) {
l.stop();
var oTT = TableTools.fnGetInstance('adjustments');
var row = oTT.fnGetSelected()[0];
var headRow = $('#adjustments').children('thead');
if (currentId == data["Id"]) {
$('#adjustments').dataTable().fnUpdate(data, row);
$(headRow).notify('Adjustment Successfully Updated', 'success', 'top');
} else {
$('#adjustments').dataTable().fnAddData(data);
$(headRow).notify('New Adjustment Created', 'success', 'top');
}
$('#EditModal').modal('hide');
},
error: function (jqXHR, textStatus, errorThrown) {
l.stop();
l.setProgress(0);
$("#error").show();
try {
var data = $.parseJSON(jqXHR.responseText);
if (data && data.Message && data.Message.length > 0) {
$("#error .message").html(data.Message);
} else {
$("#error .message").html("An unexpected error has occurred. Please contact NCQA technical support for assistance.");
}
} catch (ex) {
$("#error .message").html("An unexpected error has occurred. Please contact NCQA technical support for assistance.");
}
},
xhr: function () {
myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
myXhr.upload.addEventListener('progress',
function (evt) {
if (evt.lengthComputable) {
var percentComplete = (evt.loaded / evt.total);
l.setProgress(percentComplete);
}
},
false);
}
return myXhr;
},
});
如果我将远程桌面导入登台环境,那么在访问登台网址时一切正常