struts configure:
<struts>
<package name="web" extends="jasperreports-default, struts-default, json-default" namespace="/">
<action name="*Gsn" class="com.drug.billing.userblock.action.GsnAction" method="{1}">
<result type="json"></result>
</action>
</package>
</struts>
GsnAction.java ::
private ExecutiveInfo userBlockInfo =new ExecutiveInfo();
public String userValue(){//use json
System.out.println("select ist blur user data :");
UserBlockDao userBlockDao = new UserBlockDao();
userBlockInfo = userBlockDao.getUserBlockInfoByRegById(regById);
return Action.SUCCESS;
}
need jar : gson-2.2.4.jar
<script type="text/javascript">
function showUserValue(id){
// alert("kaniz ");
var regById = document.getElementById(id).value;
// alert(regById);
var ajaxURL = "userValueGsn.do?regById="+regById;
$.ajax({
async:false,
url : ajaxURL,
dataType:'json',
success : function(result) {
if(result.userBlockInfo!=null) {
//alert("kf"+result.userBlockInfo.userId);
$("#name").val(result.userBlockInfo.userId);
$("#userId").val(result.userBlockInfo.userId);
$("#userPass").val(result.userBlockInfo.userPass);
$("#areaName").val(result.userBlockInfo.areaName);
$("#areaExecId").val(result.userBlockInfo.areaExecId);
$("#areaId").val(result.userBlockInfo.areaId);
}
},
});
}
</script>
No comments:
Post a Comment