jQuery ajax() POST to Slim PHP framework

前端 未结 2 972
清歌不尽
清歌不尽 2021-02-10 20:29

Using jquery mobile+phonegap, trying to POST to a Slim application, I have this code:

$( document ).on( \"vclick\", \"#test_form\", function() {
            $.aj         


        
相关标签:
2条回答
  • 2021-02-10 20:48

    As per slim v3 you can access the request object with $request->getParams()

    $app->get('/', function (Request $request, Response $response){
       $data = $request->getParams()
       echo json_encode($data['namec']);
    }
    

    see documentation here https://www.slimframework.com/docs/v3/objects/request.html#route-object

    0 讨论(0)
  • 2021-02-10 20:55

    Have you tried:

    $app->post('/', function() use ($app) {
           // ...
           $req = $app->request();
           echo json_encode($req->post('namec'));
           //...
    }
    

    Also this page should help

    0 讨论(0)
提交回复
热议问题