Home > Web Front-end > JS Tutorial > body text

Convert Datatable into json and send it to the front-end implementation idea_javascript skills

WBOY
Release: 2016-05-16 17:23:19
Original
1078 people have browsed it

1. Serialize dt into json and put it in the hidden control [hidBoundary] in the foreground:

Copy the code The code is as follows:

string json = JsonConvert.SerializeObject(dtTemp);
this.hidBoundary.Value = json;

Need to reference Newtonsoft.Json.dll

2. Get the data in dt from the foreground hidden space
Copy the code The code is as follows:

var boundaryDiv = $('#hidBoundary');
if (boundaryDiv != undefined && boundaryDiv.length != 0)
{
var jsonString = boundaryDiv.val();
_jsonBoundary = jQuery .parseJSON(jsonString);
}

The parseJSON method of jQuery is used to parse the data into json format.

Vice versa, if you want to convert the json data in the frontend to the DataTable in the backend, just use the opposite method.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template