1. Use ajax
The jsp code is as follows:
$.ajax({
type:"get",
dataType:"json",
url:"<%=basePath%>actionSmUser.do?method =getUserMsgByUserId",
data:"userId=" userId,
success:function(msg){
var data = eval("(" msg.responseText ")");
alert($ ("#userName").val());
$("#userName").val(data[0].userName);
}
});
2. Use getJSON method:
$.getJSON(url,function(data){
if(data!=null && data!=""){
$("#userIdInput").val(data[0] .userId);
$("#userNameInput").val(data[0].userName);
$("#menusIdInput").val(data[0].menusId);
$ ("#depIdInput").val(data[0].depId);
$("#isValidInput").val(data[0].isValid);
$("#userIdInput").attr ("disabled",true);
}
});
The organization form of the string returned by the two Actions can be in the form of JSONArray array, returning an array. toJSONString();
Statement: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