19.5.26(Jquery的ajax方法随笔)

css:

1 line-height :20px;/*设置行间距 用于内容垂直居中 并设置高度为20px*/

ajax:

 1 $.ajax({
 2 //请求方法
 3 method: "GET",
 4 //请求地址
 5 url: "http://www.meishihui68.com.cn/api/tel?",/*GET方法注意要在末尾打?*/
 6 //预期放回的数据类型
 7 dataType: "json",
 8 //设置请求超时时间
 9 timeout: 3000,
10 //发送的数据
11 data: {
12 tel: $tel/*请求报文会写成url+tel=$tel*/
13 },
14 success: function(res) {
15 //处理Json对象res
16 //将所需值打印到界面
17 $("#address").html(res.result.mobilearea);
18 $("#yys").html(res.result.mobiletype);
19 },
20 error: function(xhr,e) {
21 //处理错误信息
22 alert("错误");
23 }
24 });

猜你喜欢

转载自www.cnblogs.com/lxdsg/p/10926232.html