html代码
<body>
<span id="show_check"></span><br />
<span id="show_flag"></span><br />
<script>
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("show_check").innerHTML=xmlhttp.responseText;
var ajax=xmlhttp.responseText;
alert(ajax[0].no1)
}
}
xmlhttp.open("GET","22.php",true);
xmlhttp.send();
</script>
</body>
---------------------------------------------------------------------------------------
22.php代码
<?php
$info = array(array('no1'=>'bsd', 'no2'=>'wuddy', 'no3'=>'xie'));
$userinfo = json_encode($info);
echo $userinfo;
?>
alert不出来json数据怎么回事呢
相关分类