我用jQuery中的load方法获得json数据,请问json数据到底放在哪了?load返回值是吗?如何处理?谢谢!

代码如下:
<html>
<head>
</head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){

$('#aa').load('profile.php');

});

</script>
<body>
<div id="aa">qq</div>

</body>
</html>
----------------------------------------------------
profile.php
<?php
$em=rand(10,100);
$arr = array(

'email' => $em,
'website' => 'http://www.okajax.com',

);
$json_string = json_encode($arr);
echo $json_string;

?>

json加载完成后就显示在div里了呀 正常的呀 帮你测试过了
你想要什么样的效果?追问

我想要获得数据,然后做其他操作用。怎么弄啊?

追答

那就不要用load这个方法呀
用ajax请求呀

$.get("profile.php",
function(data){
// data就是profile.php返回的值,但会被jquery包装成json格式,所以data是一个json对象,可直接使用
$("#aa").html(data.website);
},"json");

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-24
$.ajax({
type: "post",
dataType: "json",
url: "profile.php",
data: "r="+Math.random(),
success: function(msg){
$("#aa").html(msg.website);
}
});

这样是不是会好些?追问

谢谢。但是我想获得profile.php中的数据。php里面的那个rand我是假设为数据库中的数据.

追答

php里数据怎么查询还是跟平常查询一样
返回的数据会给success: function(msg)的msg

相似回答