AJAX异步、POST、GET提交总结一览

1、Ajax异步提交直接返回页面内容(tpl模板、html文件内容):

jQuery.ajax({
                    type: 'POST',
                    cache: false,
                    data: {'id':1},
                    url: encodeURI('提交处理路径'),
                    complete: function(rel){
                       //处理
                       //比如:$(o).parent().after(rel.responseText);
                    }
                });

2、Ajax异步提交返回JSON数据

jQuery.ajax({
                    type: 'POST',
                    cache: false,
                    data: {'id':1},
                    url: encodeURI('提交处理路径'),
                    dataType:'json',
                    success:function(rel){
                        if(rel.result == 'ok'){
                            //处理,如:var list = rel.list;...数据拼接
                         }
                     }
});


你可能感兴趣的:(AJAX异步、POST、GET提交总结一览)