apicloud链接访问本地数据库

apicloud

1,apicloud中发送ajax请求,自己练习时注意是局域网链接

        api.ajax({
          url: 'http://192.168.255.255/apicloud/xinwenapi/public/index.php/app',  //自己的局域网测试
          method: 'post', //默认返回json
          data: {
            values: {
              'name': 'wei',
              'age':22
            }
          },
        }, function (ret, err) {
          if (ret) {
            api.alert({
              msg: (ret)
            });
          } else {
            api.alert({
              msg: ('错误码:' + err.code + ';错误信息:' + err.msg + '网络状态码:' + err.statusCode)
            });
          };
        });

php返回数据

<?php
namespace app\app\controller;

class Index extends Common
{
    public function index()
    {
        $data=[
            'state'=>1,
            'msg'=>'更新成功',
            'param'=>$_POST
        ];
        return json_encode($data);
    }
}

posted @ 2022-04-02 09:47  coderwcb  阅读(163)  评论(0编辑  收藏  举报