您的位置:首页 > Web前端 > JQuery

jQuery Ajax

2016-07-17 14:05 351 查看
 <!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>
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: