Summary:
Previously shared with JS to download JSON data as CSV file, facilitate later management. But for testers who want to be able to show the task as a page, they do an example of displaying a CSV file on a page.
Code:
Copy Code code as follows:
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>
<title>csv</title>
<script src= "Http://code.jquery.com/jquery-1.11.0.min.js "></script>
<script src= "./papaparse.min.js" ></script>
<style>
html,body{
font-size:14px;
font-family: ' Microsoft yahei ', Tahoma,verdana,simsun,sans-serif;
}
Table {width:85%;margin:30px Auto;}
</style>
<body>
<table id= "Table" border= "1" >
<caption>csv Turn json</caption>
<thead>
<tr>
<th>Vehicle</th>
<th>Date</th>
<th>Location</th>
<th>Speed</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
Papa.parse ('./result.csv ', {
Download:true,
Complete:function (Results) {
var data = results.data, html;
for (var i = 1, _l = Data.length-1 i < _l; i++) {
var item = Data[i];
html + + ' <tr><td> ' +item[0].substring (1) + ' </td><td> ' +item[1].substring (1) + ' </td> <td> ' +item[2].substring (1) + ' </td><td> ' +item[3].substring (1) + ' </td></tr> ';
}
$ (' #table tbody '). Append (HTML);
}
});
</script>
</body>
Effect Chart:
Note: The above example requires a service environment