jQuery Ajax

来源:互联网 发布:mac上怎么编辑文档 编辑:程序博客网 时间:2024/06/04 18:59
 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>jQuery-ajax</title> <script type="text/javascript" src="js/jquery-2.2.3.js" ></script> </head> <body> <script type="text/javascript"> $(function () { //jQuery的 Ajax $.ajax({ url : "js/car.json", //请求路径 dataType : "json", //返回数据格式 async : true, //是否是异步,默认是异步 data : {"name" : "liushengxu"}, //参数 type : "GET", //请求方式 beforeSend : function () { console.log("======== 请求之前调用 ========="); }, success : function (data) { console.log("========= 服务器响应成功调用 =========="); console.log(data); }, error : function () { console.log("======= 服务器响应失败调用 =========="); }, complete : function () { console.log("======== 请求完毕之后调用,注意:无论服务器响应成功与否,都会调用这个函数!! ==========="); } }); }); </script> </body> </html> 
0 0
原创粉丝点击