jq ajax页面交互
2016-03-23 10:17
260 查看
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> .inp{ width: 100px; height: 100px;} .show{ width: 200px; height: 200px; border: 1px solid red;} </style> <script src="js/jquery-2.2.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var oBtn = $(".inp"); var oShow = $(".show"); var url1 = "json.json"; oBtn.click(function(){ ajax(url1); }) function ajax(url){ $.ajax({ type:"get", url:url, async:true, success:function(result){ // console.log(result); var oDate =eval(result); // console.log(oDate); oShow.append(oDate.people[1].email); } }); } }) </script> </head> <body> <input class="inp" type="button" value="button" /> <div class="show"></div> </body> </html>
json.json
{ "people":[ {"firstName":"Brett","lastName":"McLaughlin","email":"aaaa"}, {"firstName":"Jason","lastName":"Hunter","email":"bbbb"}, {"firstName":"Elliotte","lastName":"Harold","email":"cccc"} ] }
点击按钮获取 json.json中的数据 无刷新整个页面 让局部数据刷新,只需要改变json.json中的数据
相关文章推荐
- oc-18-继承
- 需要记住的的资料网址
- (转)STORM启动与部署TOPOLOGY
- Linux c日志打印
- 写博客记住自己忘记的东西
- I/O Completion Ports(完成端口)
- 使用fuel部署openstack时遇到的问题记录一下
- 深入Protobuf源码-概述、使用以及代码生成实现
- jQuery对象与dom对象
- 微信JS-SDK实现自定义分享功能,分享给朋友,分享到朋友圈,后台实现
- android实现开机自动启动Service或app
- 计算机OS是如何运行程序的
- ReactNative列表ListView
- Android屏蔽Home键、屏蔽下拉菜单最有效的办法(部分手机无效)
- 转:FORM:客制化Form的菜单栏和右鍵菜單
- js倒计时
- linux yum命令详解
- Android ViewPager+Fragment滑动选项卡,tab点击选项卡
- Application的onCreate方法被调用多次的问题
- iOS面试题