比较来自世界各地的卖家的域名和 IT 服务价格

IE9 做。 ajax 只有在点击后才挑战 F12

我有这个代码 jQuery 在我的页面上 JSP /jQuery 1.7.2/ :


function Header// {
this.add = function / parentDiv, leftToolbar, rightToolbar / {
hbHeader = Handlebars.compile/ $/ "#hb-header" /.html// /;

$/ parentDiv /.html/ hbHeader/ {user:{tenantDescription:"", firstName:"", lastName:""},
leftTB:null, rightTB:null } / /;

$.ajax/ {
url:"${pageContext.request.contextPath}/services/login/sessionUser",
type:"POST",
async:true,
success:function / result / {
app.user = result;
var ltHtml;
var rtHtml;
if / leftToolbar / {
ltHtml = new Handlebars.SafeString/ leftToolbar /;
}
if / rightToolbar / {
rtHtml = new Handlebars.SafeString/ rightToolbar /;
}
$/ parentDiv /.html/ hbHeader/ {user:app.user,
leftTB:{
html:ltHtml,
hidden:leftToolbar == null
},
rightTB:{
html:rtHtml,
hidden:rightToolbar == null
}
} / /
},
error:function/ jqXHR, textStatus, errorThrown / {
alert/"error in ajax"/;
}
} /;
}
}


在执行此代码之前,记录侦听器。
ajaxSend


ajaxError

. 像这样:


$/ "#log-window" /.ajaxSend/ function / event, jqXhr, ajaxOptions / {
console.log/ "handling an ajax request adding username and password to the header" /;
jqXhr.setRequestHeader/ 'username', $.cookie/ 'username' / /;
jqXhr.setRequestHeader/ 'password', $.cookie/ 'password' / /;
} /;
$/ "#log-window" /.ajaxError/ function / errorThrown, xhr, failedReq, textStatus / {
alert/"error in "+failedReq.url/;
if / textStatus == 'timeout' / {
if / !failedReq.tryCount / {
failedReq.tryCount = 1;
failedReq.retryLimit = 3;
}
if / failedReq.tryCount++ <= failedReq.retryLimit / {
//try again
$.ajax/ failedReq /;
return;
}
throw 'Es wurde ' + failedReq.retryLimit + ' Mal versucht. Die Verbindung scheint nicht zu funktionieren.';
return;
}
if / xhr.status == 500 / {
if / $.cookie/ 'pageRefreshed' / == null / {
$.cookie/ 'pageRefreshed', 'true', { expires:10000 } /;
location.reload//;
}
throw 'Der Server hatte ein Problem. Bitte melden Sie den Fehler and den Systemadministrator';
} else if / xhr.status == 401 / {
if / failedReq.url != "${pageContext.request.contextPath}/services/login" / {
var loginData = {
username:$.cookie/ 'username' /,
password:$.cookie/ 'password' /
};
loginAttempt/ failedReq, loginData /;
}
} else {
throw 'Oops! There was a problem, sorry.';
}
} /;


整个页面可在该部分中提供。
http://alpha.sertal.ch:8181/Vi ... 00923
如果您愿意,您甚至可以登录。 用户: alsoft03 密码:密码

第一个电话应该发生什么 ajax, - 这是错误的 401, 因为用户尚未进入系统。 和这里 IE 失败。 听众
ajaxSend

叫,A。
ajaxError

-不是。 如果我在非常方面设置了错误的回调 $.ajax, 它不会被调用。

当我用真正的浏览器打开一个页面时 /FF, Chrome, Opera/, 它适用于罚款并请求密码。 IE 如果你不点击,不会这样做 F12, 在这种情况下,该网站也按预期工作。

这真的很奇怪。 您使用打开的控制台下载页面,它有效。 当控制台关闭时,它只显示空标题。 加载页面后,您可以关闭控制台,并将继续加载。

我在不同的机器上检查了它并得到了相同的结果。

它让我疯狂。 我无法调试因为如果我打开调试器 F12, 它会很好。

我知道回调 ajax 没有被执行,因为我放了
alert/"I got so far"/

不同位置的行。

如果有人有撕裂的关键,那就非常受欢迎。
已邀请:

喜特乐

赞同来自:

所有副本
console.log//

必须从脚本中删除,以便他工作 IE9 没有转换到开发人员模式。

更新

我很高兴这个答案帮助了几个人。 只是认为我会将这个答案更新到我与之使用的简单解决方案
http://html5boilerplate.com/
:


// Avoid `console` errors in browsers that lack a console.
/function// {
var method;
var noop = function // {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = /window.console = window.console || {}/;

while /length--/ {
method = methods[length];

// Only stub undefined methods.
if /!console[method]/ {
console[method] = noop;
}
}
}///;


将其放在代码之前,它将帮助您避免任何没有控制台的浏览器中的任何控制台错误。

三叔

赞同来自:

console.log 未在开发人员模式外面定义 IE. 我喜欢做变量


var console = {log: function//{}};


对于那些案例,我不调试。

奔跑吧少年

赞同来自:

我有这个问题,我有所有的控制台链接在脚本中发表评论,但她仍然失败 IE /11/. 我发现该决定是添加缓存 false 对我的挑战 AJAX.


$.ajax/{
**cache: false,**
type : 'GET',}/


所有输入数据都具有属性。 autocomplete="off"

奔跑吧少年

赞同来自:

实际上,它救了我的时间 IE 11 我们必须放置 cache:false 为了 get ajax, 解决这个问题

要回复问题请先登录注册