Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 需要查看从成功数据到html表的整个列表元素。(需要查看列表中的所有元素)_Javascript_Html_Asp.net Core_Html Table - Fatal编程技术网

Javascript 需要查看从成功数据到html表的整个列表元素。(需要查看列表中的所有元素)

Javascript 需要查看从成功数据到html表的整个列表元素。(需要查看列表中的所有元素),javascript,html,asp.net-core,html-table,Javascript,Html,Asp.net Core,Html Table,我只需要查看列表中从成功数据到html表的所有元素。 我的列表存储在模型repo中,因此我认为不需要显示其代码。 我的cshtml页面是: @*@{Customer.Models.Customers cust = ViewBag.Customers; @{List<Customer.Models.Customers> cust = ViewBag.Customers; int id = ViewBag.oid;*@ } <html> <hea

我只需要查看列表中从成功数据到html表的所有元素。 我的列表存储在模型repo中,因此我认为不需要显示其代码。 我的cshtml页面是:

@*@{Customer.Models.Customers cust = ViewBag.Customers;
    @{List<Customer.Models.Customers> cust = ViewBag.Customers;
        int id = ViewBag.oid;*@
}
<html>
<head>
    <center><h1 style="color:red">New Entries</h1></center>
</head>
<body>
    <form id="form2">
        <table class="table">
            <thead>
                <tr>
                    <th>
                        ID
                    </th>
                    <th>
                        FNAME
                    </th>
                    <th>
                        LNAME
                    </th>
                    <th>
                        LOCATION
                    </th>
                    <th>
                        CONTACT
                    </th>
                    <th>
                        EMAIL
                    </th>

                    <th>
                        PASSWORD
                    </th>

                    <th>
                        CATEGORY
                    </th>
                    <th>
                        STATUS
                    </th>

                    <th></th>
                </tr>
            </thead>
            <tbody>

                    <tr>

                        <td id="Id"></td>
                        <td id="Fname"></td>
                        <td id="Lname"></td>
                        <td id="Location"></td>
                        <td id="Contact"></td>
                        <td id="Email"></td>
                        <td>**********</td>
                        <td id="Category"></td>
                        <td id="Status"></td>
                        <td><button type="button" class="btn btn-primary" id="approve" @*onclick="location.href='@Url.Action("Approve", "Home", new { cust1.Id})'"*@>Approve/Reject</button></td>
                        <td><button type="button" class="btn btn-primary" id="log" @*onclick="location.href='@Url.Action("pro","Home",new { cust1.Id })'"*@>Activity Log</button></td>
                    </tr>
                @*}*@
                <tr>
                    <td><button type="button" class="btn btn-primary" id="back" @*onclick="location.href='@Url.Action("Details", "Home", new { id})'"*@>Back</button></td>
                </tr>



            </tbody>
        </table>
    </form>
</body>
</html>

@section Scripts{
<script>
    var id = localStorage.getItem("empid");
    $.ajax({
    contentType: "application/json",
    type: "GET",
    url: "https://localhost:44397/api/Values/Addap",
    success: function (data) {

    res = data;

    document.getElementById("Id").innerHTML = res.id;
    document.getElementById("Fname").innerHTML = res.fname;
    document.getElementById("Lname").innerHTML = res.lname;
    document.getElementById("Location").innerHTML = res.location;
    document.getElementById("Contact").innerHTML = res.contact;
    document.getElementById("Email").innerHTML = res.email;
   // document.getElementById("Password").innerHTML = res.password;
    document.getElementById("Category").innerHTML = res.category;
    document.getElementById("Status").innerHTML = res.status;

    },
    error: function (jqXHR, textStatus, errorThrown) {
    $("#postResult").val(jqXHR.statusText);
    }
    });
    </script>
}
@*{Customer.Models.Customers cust=ViewBag.Customers;
@{List cust=ViewBag.Customers;
int id=ViewBag.oid*@
}
新条目
身份证件
FNAME
名字
地方
联系
电子邮件
暗语
类别
地位
**********
批准/拒绝
活动日志
@*}*@
返回
@节脚本{
var id=localStorage.getItem(“empid”);
$.ajax({
contentType:“应用程序/json”,
键入:“获取”,
url:“https://localhost:44397/api/Values/Addap",
成功:功能(数据){
res=数据;
document.getElementById(“Id”).innerHTML=res.Id;
document.getElementById(“Fname”).innerHTML=res.Fname;
document.getElementById(“Lname”).innerHTML=res.Lname;
document.getElementById(“Location”).innerHTML=res.Location;
document.getElementById(“Contact”).innerHTML=res.Contact;
document.getElementById(“Email”).innerHTML=res.Email;
//document.getElementById(“密码”).innerHTML=res.Password;
document.getElementById(“Category”).innerHTML=res.Category;
document.getElementById(“Status”).innerHTML=res.Status;
},
错误:函数(jqXHR、textStatus、errorshown){
$(“#postResult”).val(jqXHR.statusText);
}
});
}
这里抛出的值未定义。 我需要查看列表中的所有值。
你能帮我吗。可以根据需要提供任何其他信息。

如果返回的结果是json,则可以尝试以下代码:

<center><h1 style="color:red">New Entries</h1></center>

<form id="form2">
  <table class="table" id="tbList">
    <thead>
        <tr>
            <th>ID</th>
            <th>FNAME</th>
            <th>LNAME</th>
            <th>LOCATION</th>
            <th>CONTACT</th>
            <th>EMAIL</th>

            <th>PASSWORD</th>

            <th> CATEGORY</th>
            <th> STATUS</th>

            <th></th>
        </tr>
    </thead>
    <tbody>

    </tbody>
    <tfoot>
        <tr>
            <td><button type="button" class="btn btn-primary" id="back">Back</button></td>
        </tr>
    </tfoot>
  </table>
</form>

@section Scripts{
  <script>
        $.ajax({
            type: "GET",
            url: "https://localhost:44343/api/Values/Addap/",
            success: function (data) {
                $.each(data, function (index, obj) { 
                    var row = '<tr><td> ' + obj.id + ' </td> <td> '
                        + obj.fname + ' </td> <td>'
                        + obj.lname + '</td> <td>'
                        + obj.location + '</td> <td>'
                        + obj.contact + '</td> <td>'
                        + obj.email + '</td> <td>**********</td> <td>'
                        + obj.category + '</td> <td>'
                        + obj.status + '</td>'
                        +'<td> <button type="button" class="btn btn-primary" id="approve">Approve/Reject</button></td>'
                        +'<td><button type="button" class="btn btn-primary" id="log">Activity Log</button></td> </tr>'
                    $("#tbList tbody").append(row);
                }); 
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert('Failed!');
            }
        });
  </script>
}
新条目
身份证件
FNAME
名字
地方
联系
电子邮件
暗语
类别
地位
返回
@节脚本{
$.ajax({
键入:“获取”,
url:“https://localhost:44343/api/Values/Addap/",
成功:功能(数据){
$.each(数据、函数(索引、对象){
变量行=“”+obj.id+“”
+obj.fname+“”
+obj.lname+“”
+对象位置+“”
+obj.触点+“”
+obj.email+“************”
+对象类别+“”
+对象状态+“”
+“批准/拒绝”
+“活动日志”
$(“#tbList tbody”)。追加(行);
}); 
},
错误:函数(jqXHR、textStatus、errorshown){
警报('Failed!');
}
});
}
控制器:

    [HttpGet]
    public async Task<IActionResult> Addap()
    {
        var user = await _context.User.ToListAsync();
        return new JsonResult(user);
    }
[HttpGet]
公共异步任务Addap()
{
var user=wait_context.user.toListSync();
返回新的JsonResult(用户);
}