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

ajax同步异步回调函数问题

ajax同步:req.open(‘get’,url,false);

实例:

js方法

    var g_success =false;//全局变量

    function getUser(username){

     if("" == username){

         alert("登录名不能为空!");

         return;

     }

     g_success = false;

     var url = "<%=path%>/basicdata/gyshtyCheckUsername.do?mode=getUser&username="+encodeURI(encodeURI(username));

     if (window.XMLHttpRequest) {

         req = new XMLHttpRequest();

     } elseif (window.ActiveXObject) {

         req = new ActiveXObject("Microsoft.XMLHTTP");

     }

     if (req) {

   &nbs