我想要在找到的function.Ie中获取dwr方法的返回值,我有一个javascript函数名为checkvalue().Within,我有一个DWR调用。我想要通过DWR方法返回的值。我已经将值设置为隐藏的variable.But它无法获取properly.How。我可以这样做吗?请帮助我。
谢谢
<script type="text/javascript">
function checkvalue(applNo){
classDAO.getstatusofApplication(applNo,getstatusofApp);
var status=document.getElementById("hiddenfield").value;
}
function getstatusofApp(status){
document.getElementById("hiddenfield").value=status;
}
</script>在上面的例子中,我将dwr返回值'status‘设置为一个隐藏字段,并调用检查值method.But中的隐藏字段,它显示为null。
发布于 2016-03-18 13:37:15
我认为在你的代码中有一行
var status=document.getElementById("hiddenfield").value;在调用函数getstatusofApp之前执行。尝试在控制台中登录代码执行的步骤。
所以你真正应该做的是-
function checkvalue(applNo){
classDAO.getstatusofApplication(applNo, function(status){
getstatusofApp(status);
alert(status);
// here you have the status value you need not have
// to read it from hidden variable
});
}https://stackoverflow.com/questions/35697545
复制相似问题