js部分:
function getMatch(page){ $.ajax({ url:"http://gms.sgamer.com/index.php?g=Dota2&m=Api&a=getMatchinfo&p=" + page, dataType:'jsonp', jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(默认为:callback) jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名 success:function(e){ console.log(e); } }); }
php部分:
public function getMatchinfo(){ $p = I('p') ? I('p') : 1; $limit = ($p-1)*9; $model = D('Dota2Matchinfo'); $count = $model->where($Map)->count(); $data = $model->where($Map)->order("id DESC")->limit($limit,9)->select(); $page = $this->new_page($count,9,$p); $_data['match'] = $data; $_data['count'] = $count; $_data['page'] = $page; $callback = $_GET['callback']; echo $callback.'('.json_encode($_data).')'; exit(); }