我是这种方法的新手。当我加载记录并将其放入数据表时,我收到了请求超时错误。我使用SP进行查询,当我测试它时它运行不到一秒钟。但是在我的页面中无法做到。
items.vbhtml
<div class="pnl_viewlist">
<div class="row" style="padding-bottom:10px;">
<div class="col-lg-12">
<div class="panel">
<div class="panel-heading">
<h5>Product List</h5>
</div>
<div class="panel-body">
<div class="table-responsive">
<table id="tbl_items" class="table table-responsive">
<thead>
<tr class="bg-light">
<th class="text-center">Image</th>
<th>Item</th>
<th>Description</th>
<th>Price</th>
<th>Unit</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
项目控制器
Function items_view() As ActionResult
Return View()
End Function
<HttpPost>
<ValidateAntiForgeryToken>
Function product_catalog(obj As masters.Items) As JsonResult 'function name
Dim product_catalog_in = ws_masters.items_in_up(obj, Session("company_no"), Session("user_id"), Session("user_group_title")) 'from asmx
Return Json(product_catalog_in, JsonRequestBehavior.AllowGet)
End Function
<HttpGet>
Function item_code_view_sel() As JsonResult
Dim item_code As New List(Of masters.items)(ws_masters.item_code_sel_view())
Return Json(item_code, JsonRequestBehavior.AllowGet)
End Function
<HttpGet>
Function item_list(item_id As Int32) As JsonResult
Dim items As New List(Of masters.items)(ws_masters.item_view_sel(item_id, Session("company_no")))
Return Json(items, JsonRequestBehavior.AllowGet)
End Function
<HttpPost>
Public Function upload_item_image(item_id As Int32) As JsonResult
Dim _url_file_name As String = ""
Try
If Request.Files.Count > 0 Then
For Each uploaded_file As String In Request.Files
Dim fileContent = Request.Files(uploaded_file)
If fileContent IsNot Nothing AndAlso fileContent.ContentLength > 0 Then
Dim fileName = Path.GetFileName(uploaded_file)
_url_file_name = "/Images/users/" + fileName
fileContent.SaveAs(Path.Combine(Server.MapPath("~/Images/users"), fileName))
ws_masters.update_item_image(_url_file_name, item_id)
End If
Next
Else
Return Json("No Selected File", JsonRequestBehavior.AllowGet)
End If
Catch generatedExceptionName As Exception
Return Json("Upload failed", JsonRequestBehavior.AllowGet)
End Try
Return Json(_url_file_name, JsonRequestBehavior.AllowGet)
End Function
items.js
function load_item_list() {
$.ajax({
url: "/master/item_list?item_id=0",
type: "GET",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
var vdatatable = $("#tbl_items").DataTable();
vdatatable.clear();
vdatatable.draw();
$.each(result, function (key, item) {
vdatatable.row.add(["<img src='"+ item.thumb_path + "' class='img-thumbnail img-responsive thumb' style='width:50px;' />", "<a href='#' onClick='item_details(\"" + item.item_id + "\");'>" + item.item_code + "</a>", item.item_desc, item.price, item.uom_code]).draw();
});
},
error: function (errormessage) {
console.log(errormessage.responseText);
}
});
}
请详细解答。这个方法刚刚开始。非常感谢!