1,apicloud中发送ajax请求,自己练习时注意是局域网链接
api.ajax({
url: 'http://192.168.255.255/apicloud/xinwenapi/public/index.php/app',
method: 'post',
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);
}
}