js这样写:
$.ajax({ url: "http://m.o2.qq.com/Api/rerunMonitor",// The name of the callback parameter,as specified by the YQL service jsonp: "callback",// Tell jQuery we're expecting JSONP dataType: "jsonp",// Tell YQL what we want and that we want JSON data: { monitorID: monitor_id },// Work with the response success: function( response ) { console.log( response ); // server response vm.isupdate=(vm.isupdate==0?1:0); button.html('重跑'); button.prop('disabled',false); } });
PHP这样写:
public function rerunMonitor(){ $monitorID = $_GET["monitorID"]; if($monitorID==null||$monitorID==''){ $ret="monitorID缺失"; }else{ $this->load->model('material_model','material'); $model = $this->material; $data = $model->apiGetMonitor($monitorID); $date=$data[0]['date']; $job=$data[0]['job']; $cmd = "/usr/local/PHP/bin/PHP /data/www/m.o2.qq.com/application/shell/$job.PHP $date"; $ret = exec($cmd); } $callback=$_GET['callback']; echo $callback."('$ret')"; }
成功,cosole.log输出了PHP服务器传来的response。
参见https://learn.jquery.com/ajax/working-with-jsonp/
http://justcoding.iteye.com/blog/1366102/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。