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://www.f2er.com/json/289162.html