How to set the thinkphp5 request type?
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-03 11:40:31
0
1
556

1. Question:
I need to write a judgment on the controller page. If the data is passed by ajax, the database will be searched. Otherwise, the page will be displayed directly.
I have been unable to obtain data using the condition request()->isAjax(). I don’t know if it is correct. Could you please help me, thank you~

2.Code

<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Request;
class User extends Controller{
//新增用户
    public function add_user(){
        if (request()->isAjax()){
            $data = input('post.');
            p($data);die;
        }else{
            return $this -> fetch(); 
        }
    }
女神的闺蜜爱上我
女神的闺蜜爱上我

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!