jquery ajax代码详解

下面我们来获取一个城市的天气信息,通过这个简单例子,在代码中jquery ajax的功能进行详细注解
例子如下:
jquery ajax代码详解_第1张图片
以下为请求的服务器文件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;

}

你可能感兴趣的:(php进阶学习)