Jquery的同步和异步请求

   1 异步请求:
    1.1 $.ajax
       $.ajax({
                url : 'your url',
                data:{name:value},
                cache : false,
                async : true,
                type : "POST",
                dataType : 'json/xml/html',
                success : function (result){
                    do something....
                }
            });
    2 同步请求
    2.1 $.ajax
       $.ajax({
                url : 'your url',
                data:{name:value},
                cache : false,
                async : false,
                type : "POST",
                dataType : 'json/xml/html',
                success : function (result){
                    do something....
                }
            });
    2.2 $.post
      $.post(
                'your url',
                {name:value},
                function(data) {
                    do something...
                },
            'json/xml/html'
            );

posted @ 2017-08-23 11:02  xuyatao  阅读(2008)  评论(0编辑  收藏  举报