reactjs入门到实战(九)----ajax的应用
2016-06-06 17:29
671 查看
利用外部的jquery:
<script type="text/babel"> var Count = React.createClass({ getInitialState:function(){ return{ count:0 } }, componentDidMount:function(){ this.timer =setInterval(function(){ $.get('http://ip/apishow/pv.php',function(data){ var obj = eval('(' + data + ')'); this.setState({count:obj[0]['value']}); }.bind(this)) }.bind(this),1000) }, render:function(){ return ( <div> <a>PV: {this.state.count} </a> </div> ); } }); ReactDOM.render( <Count />, document.getElementById('example') ) </script>
相关文章推荐
- reactjs入门到实战(八)----表单组件的使用
- react-native 把图片转化base64字符串
- 使用React.js 重新构建HipChat
- react native 代参bind this 的两种方式
- Reactjs 入门基础(二)
- ReactNative 踩坑小计
- react-native Simulator com+r不能刷新模拟器
- 从 ReactiveCocoa 中能学到什么?不用此库也能学以致用
- React Native系列——微信分享
- [Redux] Filtering Redux State with React Router Params
- React Native学习笔记(三)组件生命周期
- reactjs入门到实战(六)---- ReactJS组件API详解
- ReactNative环境配置问题
- React Native环境配置
- React Native移植到原生Android项目
- React入门笔记(五) — 表单详解
- reactjs入门到实战(五)---- props详解
- 在终端terminal运行ReactNative程序经常出现的问题
- reactjs入门到实战(四)---- state详解
- ReactiveCocoa 用 RACSignal 替代 Delegate