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

jquery怪问题,求解,,,,,,,,
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
  <title>Untitled Page</title>
   
  <script type="text/javascript">
  function submitCheck()
  {  
  $.ajaxSetup({ 
  async: false //如果想同步 async设置为false就可以(默认是true)
  }); 
  var reStrState="";
  var str=GatewayInfo();
  $.ajax({
  type: 'POST',
  url: 'http://www.test.com/AjaxPostUserCheck.ashx',//http://localhost/AjaxPostUserCheck.ashx

  data: {
  postUserInfo:str
   
  },
  dataType: 'jsonp', //
  success: function (data) {
  alert("dddd");/////////////////////////// 我是第二个
  switch(data.postReHotType)
  {  
  case"2":
  $.ajax({
  type: 'POST',
  url: 'http://www.test.com/AjaxPostUserCheckDo.ashx',//http://localhost/AjaxPostUserCheckDo.ashx
  data: {
  postUser:str,
  postDataName: $("#TbxName").val(),//
postDataPwd: $("#TbxPwd").val()//
},
  dataType: 'jsonp', //
  success: function (data) {
  reStrState=data.ReUser
  alert(reStrState);////////////////////我是第三个
  }
  });
   
  break;
  default:
  reStrState="T";
  break;
  }
   
  }
  });

  alert("我是|"+reStrState)//////////////////////////我是第一个
   
  if(reStrState=="T")
  {
  alert("ccccccccccccccccccc")/////////////////////
  return true;
  }else
  {
  alert("zzzzzzzzzz")///////////////////////////////我是第四个
  return false;
  }
  }
   
  </script>
</head>
<body>
<form action="http://test.com">
<input type="submit" onclick ="return submitCheck()" value="提交" />
</form>
</body>
</html>

  //当两个url地址为本地地址时提示的顺序是 第二个,第三个, 第一个, 第四个,
  //当两个url地址为跨域地址时提示的顺序是 第一个,第二个, 第三个,第四个,
   
  //希望跨域的顺序和本地的一样, 要不然 reStrState=data.ReUser 赋值后不起作用 执行的顺序都是先执行
 
  alert("我是|"+reStrState)//////////////////////////我是第一个
   
  if(reStrState=="T")
  {
  alert("ccccccccccccccccccc")/////////////////////
  return true;
  }else
  {