<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>json pass value test</title>
<style>
td{
background:#066;}
</style>
</head>
<body>
<table border="1" id="name">
</table>
<button id="test" value="test" type="button">test</button>
<script src="jquery.js" type="text/javascript"></script>
<script>
/* Traditional json pass value
$(function(){
$("#test").click (function(){
$.getJSON('tablejsontest.json',function(data){
$('#name').empty();
var html = '';
$.each(data,function(nameIndex,name){
html +='<tr><td>' + name['name'] + '</td><td >' + name['sex'] + '</td><td>' + name['school'] + '</td></tr>';
})
$('#name').html(html);
})
})
})
*/
//json pass value in ajax
$(function(){
$('#text').click (function(){
$.ajax({
type:"GET",
url:"tablejsontest.json",
dataType:"json",
success:function(data){
$('#name').empty();
var html ='';
$.each(data,function(nameIndex,name){
html +='<tr><td>' + name['name'] + '</td><td >' + name['sex'] + '</td><td>' + name['school'] + '</td></tr>';
});
$('#name').html(html);
}
});
});
})
</script>
</body>
</html>
The tablejsontest.json code is as follows:
[
{
"name":"anna",
"sex":" ",
"school":"The First Middle School"
},
{
"name":"jon",
"sex":"man",
"school":"The Third Middle School"
}
]
jquery ajax post pass an array of multiple checkbox values Use $ .each (function () {}); the corresponding values obtained checkbox, The traditional need to be set to true when ajax upload ...
Result graph: One, Action class Two, configure Struts Three, pass jqury on the html page to obtain a single value...
HTML format data XML format data JSON format data...
Ajax is a frequently used technique, in addition to the self-encapsulation, JQuery also encapsulates Ajax, so the AJAX method encapsulated by jQuery is first defined from jQuery, naturally to introduc...
The ajax parameter of the jquery framework is in addition to the usual There is also a parameter that needs special attention.traditionalThe default is false. When ajax does data processing, it is pas...
In ajax parameter passing in string delimiter spread apart to the background, and then split in the background. This led to arguments passed can not contain a comma, the security implications of the p...
Scenes inspinia front-end page template+thymeleaf template+jquery+springboot Click Submit to transmit the id of the currently selected row to the backend as a json string, and the backend will impleme...
JSP page: Background control class: These two sentences must be added to return the json value...
JSON (JavaScript Object Notation) is a simple data format that is lighter than xml. JSON is a JavaScript native format, which means that no special APIs or toolkits are required to process JSON data i...
Introduction JSON (JavaScript Object Notation) is a lightweight data exchange format. Easy for people to read and write. Cakephp 1.2 provides built-in support for JSON, mainly in two special ways: Rou...