</body>
controller:
@ResponseBody
@RequestMapping("testJson")
public List<User> testJson(String username,String age){
System.out.println(username+"---"+age);
List<User> userList=userService.getUsers();
return userList;
}
Note that there is only one button when entering the page for the first time, and the form is hidden when it comes in. When the button is clicked, the list collection is queried from the background and passed to the front end in the form of a json array. The value is displayed in the table and displayed in the front end loop.
var row=$("#template").clone(); means to copy the template, row.find("#username").text(user.userName); means to find a column with id called username in the row Make content assignments. Use $.each(data,function(i,user){}) here. The user here is already a looped object, equivalent to user=data[i], which can be used directly. Finally, pass row.appendTo( $("#tables")); Add the content of the template to the table.
The effect is as follows:
Add a new field to the json array returned in the background ...
The JSON text into a JavaScript object One of the most common use of JSON, read JSON data from the web server (as a file or as an HttpRequest), the JSON data into JavaScript objects, and then use that...
Background code (file nameajax.php) Front-end code (file name ajax.html) Bind the ajax event to the button. When there is no input number or other content, a warning window will pop up, prompting &quo...
Recently I found a problem when using jquery's ajax method to receive json data, that is, the returned data data, sometimes can be used directly as json data, the specific elements can be obtained wit...
Finding reliable information on the Internet is really as difficult as finding a needle in a haystack. Ok, don't talk nonsense, post the code that runs correctly. Prerequisites: apache has been starte...
Through Ajax to request the json format data on the remote server to be parsed and displayed Enter in the browser: http://localhost/ajaxTest.php Enter Then you can see this rendering:...
Later, I searched for information and found that although the data was loaded after the new node was added, the style was not loaded, so there are two points to note in the whole process. 1. Use loops...
Today, when completing the javaweb experiment, the json data returned in the background was filled into the jsp table for a long time. I used the javaex front-end framework, and the method is now reco...
The format of the content returned by the interface is similar to the following json string. How to parse it with C# and get the value in it?...