直接上代码:
前端:
<script src="./jquery-1.11.2.min.js"></script> <script> $(function () { $('#btn').click(function () { var url = "http://www.test.com/index.php/index/index/gt"; $.get(url, (res) => { console.log(res); }, 'jsonp') }); }) </script>
后端:(thinkphp5.0)
public function gt() { $dd = input('param.callback'); $this->dd = db('e_ad', false); $res = $this->dd->order('id')->select(); $data = json_encode($res); echo $dd . '(' . $data . ')'; }
标签:function,index,gt,跨域,res,dd,ajax,jsonp From: https://www.cnblogs.com/haokan/p/17044019.html