想要從asp.net mvp服務器端加載數據。 有jQuery的Ajax的功能:jQuery Datatables加載數據ajax
Function GetData() As ActionResult
Dim TransactionSearchRow1 = New TransactionSearchRow With {
.status = Status.Cancelled,
.transactionId = "12345",
.creditCardNumber = "1234324324",
.supplier = "Office Depot",
.createdAt = New DateTime(2008, 12, 28),
.amount = 500
}
Dim anon = New With {.data = New List(Of TransactionSearchRow) From {TransactionSearchRow1}}
Dim jsonData As String = JsonConvert.SerializeObject(anon, Formatting.Indented)
Return Json(jsonData)
End Function
但沒有什麼是發生時,即時通訊點擊BTN:即返回我1行數據的
$("#SearchBtn").on("click", function() {
$.ajax({
url: '/Transaction/GetData',
success: function (dataReturend) {
$("#TransactionTable").DataTable({
ajax: '/Transaction/GetData',
data: dataReturend,
columns: [
{ data: 'status' },
{ data: 'transactionId' },
{ data: 'creditCardNumber' },
{ data: 'supplier' },
{ data: 'createdAt' },
{ data: 'amount' }
]
});
}
});
});
JSON格式:寫在你的單擊事件大火不需要的2倍
{
"data": [
{
"status": 2,
"transactionId": 12345,
"creditCardNumber": "1234324324",
"supplier": "Office Depot",
"createdAt": "2008-12-28T00:00:00",
"amount": 500.0
}
]
}
你能告訴你的迴應JSON的樣子 – Ashish451
是SRY加入現在 –
能否請您提供它以JSON格式互不發佈圖片? –