1. SencharTouch jsonp 请求服务器的代码 Ext.data.JsonP.request({ url: 'http://www.57lehuo.com/jsonp.php', params: { //传递参数 username : 'zhangsan' , password: 'nihao' }, timeout: 30000,//超时时间 callbackKey: '',//回调函数名,默认为callback callback: function() { //回调函数,不管请求成功与否都执行 }, success: function(result) { //请求成功时执行捉拿 component.setValue({ month: result.month, day : result.day, year : result.year}); }, failure: function() { //请求失败时执行操作 } });2.php后端代码 $callback = $_REQUEST['callback']; $username=$_REQUEST['username']; $password=$_REQUEST['password']; $resutl=array('username'=>$username,'password'=>$password); //start output if ($callback) { echo $callback . '(' . json_encode($resutl) . ');'; exit; } else { echo json_encode($resutl); exit; } |
Archiver|手机版|小黑屋| PhoneGap中文网 ( 京ICP备13027796号-1 )
GMT+8, 2024-11-11 05:40 , Processed in 0.062143 second(s), 22 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.