1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 <script src="js/jquery-1.12.3.js"></script> 7 <script> 8 $(function(){ 9 10 //$.get() 11 //$.post() 12 //$.ajax() 13 /* 14 type: 请求方式 15 url: 接口 16 data: 参数 17 async: 是否异步 18 success: 成功后的回调 19 error: 失败后的回调 20 complete: 完成后的回调 21 * */ 22 /* 23 $.ajax({ 24 //type:"get", 25 url: "json/football.json", 26 //data: {}, 27 //async: true, //默认是异步 28 29 success: function(data){ 30 31 console.log(data); 32 33 }, 34 error: function(){ 35 // console.log(arguments[0]); 36 // console.log(arguments[1]); 37 // console.log(arguments[2]); 38 console.log("error"); 39 }, 40 complete: function(){ 41 console.log("complete"); 42 } 43 }) 44 console.log("我是最先被调用的"); 45 */ 46 47 //$.get() 48 // $.get("http://60.205.181.47/myPHPCode2/checkname.php?regname=zhangsan", function(data){ 49 // //console.log( JSON.parse(data).msg ); 50 // console.log("get"); 51 // }) 52 53 $.get("http://60.205.181.47/myPHPCode2/checkname.php", {regname:"zhangsan"}, function(data){ 54 console.log("get"); 55 }) 56 57 //$.post() 58 $.post("http://60.205.181.47/myPHPCode2/checkname.php", {regname:"zhangsan"}, function(data){ 59 console.log("post"); 60 }) 61 62 63 64 }) 65 </script> 66 </head> 67 <body> 68 </body> 69 </html>