日期:2014-05-16  浏览次数:20304 次

JQ输出HTML内容,有时能输出有时不行,特别是IE,firefox正确显示
$.post("/res/ashx/onlineTest.ashx?a=getUserInfo", function (d) {
  if ($.trim(d) == "noInfo") {
  top.location = "/default.html";
  }
  else {
  $("#userInfo").html("姓名:" + $.trim(d).substring($.trim(d).indexOf("|", 0) + 1, $.trim(d).length) + " 身份证号:" + $.trim(d).substring(0, $.trim(d).indexOf("|", 0)));
  getLeftTime();
  }
});

功能是去到服务器获取信息,但在IE中不能直接显示,F5刷新后也不显示,要在地址栏按一下回车,才能显示userInfo内容,但是FIREFOX能正常显示出来,这是为什么呀,谢谢

-------------------

$.post("/res/ashx/onlineTest.ashx?a=getUserInfo" + "&nocache=" + new Date(), function (d) {
  if ($.trim(d) == "noInfo") {
  top.location = "/default.html";
  }
  else {
  alert(""); $("#userInfo").html("姓名:" + $.trim(d).substring($.trim(d).indexOf("|", 0) + 1, $.trim(d).length) + " 身份证号:" + $.trim(d).substring(0, $.trim(d).indexOf("|", 0)));
  getLeftTime();
  }
});

中间加了个alert(""),就肯定能正确显示,这是为什么呀,难道是绑定时没有获取数据?要慢一点?

谢谢!

------解决方案--------------------
探讨

把所有要绑定的代码放在
$(document).ready(function(){


});里就可以了,谢谢兄弟们