jquery ajax代码详解

下面我们来获取一个城市的天气信息,通过这个简单例子,在代码中jquery ajax的功能进行详细注解
例子如下:
ajax
以下为请求的服务器文件weather_get.php
if(isset(KaTeX parse error: Expected 'EOF', got '&' at position 8: _POST) &̲& !empty(_POST)){
c i t y c o d e = citycode= citycode=_POST[‘citycode’];//得到城市代码
r e s = f i l e g e t c o n t e n t s ( " h t t p : / / w w w . w e a t h e r . c o m . c n / d a t a / s k / res=file_get_contents("http://www.weather.com.cn/data/sk/ res=filegetcontents("http://www.weather.com.cn/data/sk/citycode.html");//从外网获取信息将

文件的内容读入到一个字符串中
// var_dump($res);
r e = j s o n d e c o d e ( re=json_decode( re=jsondecode(res);//json解码
unset( r e − > w e a t h e r i n f o − > W S E ) ; / / 删 除 读 取 到 信 息 中 的 W S E 字 符 串 / / v a r d u m p ( re->weatherinfo->WSE);//删除读取到信息中的WSE字符串 // var_dump( re>weatherinfo>WSE);//WSE//vardump(re);
echo json_encode($re);//json编码
// echo $res;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值