jquery 同步和异步的请求方式

来源:互联网 发布:嵌入式linux开发工具 编辑:程序博客网 时间:2024/06/08 18:19

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'
            );

原创粉丝点击