如何使用ajax接收后台传过来的数据

如题所述

一般情况下 后台传回JSON字串 

前端收到以后先转成json 对象  然后遍历取出 数值 刷新页面组件...

var jsonOprtInfo;
Ext.Ajax.request({
url: "php/tools/get_user_tips.php",method: 'POST',async : false,scope: this,
success: function(response, options) {
 jsonOprtInfo = Ext.util.JSON.decode(response.responseText);
            document.getElementById("top_user").innerHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" ><img src = '/images/opr.png' width = 36px height = 36px /></td></tr><tr><td align=\"center\" height = 30px>用户:" + jsonOprtInfo.OprtPowerInfo.OprtNo +"</td></tr></table>";  // jsonOprtInfo.OprtPowerInfo[0].OprtNo
            
            document.getElementById("top_group").innerHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" ><img src = '/images/usergroup.png' width = 36px height = 36px /></td></tr><tr><td align=\"center\" height = 30px>组:" + jsonOprtInfo.OprtPowerInfo.OprtName +"</td></tr></table>";  // jsonOprtInfo.OprtPowerInfo[0].OprtNo
            
            document.getElementById("top_exit").innerHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\"><a href=\"javascript:void(0);\" onclick=\"AppLoginOut();\"><img src = '/images/forward.gif' width = 36px height = 36px /></a></td></tr><tr><td align=\"center\" height = 30px>退出</td></tr></table>";
            },
            });

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-08-01
" "这个整体不含引号就代表一个空格,多个空格只需复制黏贴就OK了。祝你好运!
相似回答