利用jquery发送ajax请求的几个模板代码。

$.ajax({  
    async : false, 
    type: \'POST\',  
    dataType : "json",  
    url: "v_tree.do",
    data:{},
    error: function (XMLHttpRequest, textStatus, errorThrown) {//请求失败处理函数  
    alert(\'请求失败\' + errorThrown);  
    },  
    success:function(data){ //请求成功后处理函数。    
    }  
});

另一个例子:

$.ajax({
    type: "GET",
     url: "test.json",
     data: {username:$("#username").val(), content:$("#content").val()},
     dataType: "json",
     success: function(data){     
     },
     error: function(data){     
     }
 });

版权声明:本文为tq03原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/tq03/p/4105697.html