mardi 18 février 2020

Display laravel retrun result in html table using jquery- Ajax

In Laravel Blade I have a script for searching

 <script type="text/javascript">
    $.ajax({
        type: "POST",
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          },
        url: "",
        data: dataString,
        dataType:"JSON",
        cache: false,
        success: function(result) { 
        var FinalResult=result.CallDetails
        num_rows = result.length;
        console.log(result)


        },error:function(x,e) {
            setTimeout(function() {searchPhoneCalls();}, 2000);
        }
    })
</script>

search function in controller returns is below

return json_encode($users);

In console am getting the result as an array like below

0: {Short_name: "GO120762", Date: "21-01-2020"}
1: {Short_name: "GO120764", Date: "21-01-2020"}
2: {Short_name: "GO120766", Date: "21-01-2020"}

I want to display those result in a HTML table like below

+----------+------------+
| Name     | Date       |
+----------+------------+
| GO120762 | 21-01-2020 |
+----------+------------+
| GO120764 | 21-01-2020 |
+----------+------------+
| GO120766 | 21-01-2020 |
+----------+------------+



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SWODdw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire