页面就绪后调用 genQRCode(); post调用 其他php页面 从数据库取数据 如果json结果为有效 则再调用 php页面生成二维码 返回文件路径 并显示
$(document).ready(function () {
genQRCode();
});
//get access qrcode
function genQRCode() {
var selected_val= "NG";
var vsel = document.getElementById("mregionid");
if (vsel !=null)
{
selected_val = document.getElementById("mregionid").value;
}
else
{
selected_val = vdefgid;
}
//alert(selected_val);
//alert('<?php echo $szopenid;?>');
//alert(selected_val);
// if (selected_val.length < 5)
// {
// $("ttip").text = "您目前还没有开门权限请联系设备管理员";
// return;
// }
$.post("devdir.php", {mprotype: '0', mtrick: '123',mOpenID: '<?php echo $szopenid;?>',mregionid:selected_val},
function(data){
//alert(data);
if (data.length > 30)
{
var jsonStr = JSON.parse(data);
// alert(jsonStr.repsonse);
//alert(jsonStr.adata);
// alert(jsonStr.repsonse =="00000");
if (jsonStr.repsonse == "00000")
{
$.post("../encrpt/d.php", {mdata : jsonStr.adata},
function(imgdata){
//alert(imgdata);
//var vv = data.substr(0,4);
//alert(vv);
//if (data.substring(0,4) == \"http\")
// {
document.getElementById("qrcodeimg").src = imgdata;
// }
});
}
}
});
}