• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Ajax request fetching data from database and return it

I am trying to make a simple ajax request that in the controller can fetch the data from the db and return it. Right now I have this code on the view:

$(".btn-submit").click(function(e){

    e.preventDefault();        var name = $("input[name=name]").val();      var password = $("input[name=password]").val();      var email = $("input[name=email]").val();        $.ajax({          type:'POST',          url:'/ajaxRequest',          data:JSON.stringify({name:name, password:password, email:email}),          dataType: "json",           success:function(data){              console.log(data.lots);              alert(data.success);              $("#id").append(data.lots);      }});   }); 

And this code on controller:

public function ajaxRequestPost(Request $request)

{      $input = $request->all();      $result = DB::select('select * from users');      $enc = json_encode($result);      $ht="

TESTE

"; return response()->json(['success'=>'Got Simple Ajax Request.', 'lots'=>$enc]); }

How can I echo every row of the variable $enc on the view ?

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]