我的响应看起来是这样的:JSON - 如何提取从Django响应收到的数据?
[{ “0”: “[email protected]”},{ “1”: “[email protected]”},{ “2”:“N @ n.com“},{”3“:”[email protected]},{“4”:“[email protected]”},{“5”:“[email protected]”},{“6 “:‘[email protected]’}]
我想通过以下HTML阅读本:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
document.write('Getting JSON response...');
$.getJSON(<my django url>,
function(data) {
alert("receiveng"+data["0"]);
});
});
</script>
</head>
<body>
</body>
</html>
但我没有得到任何警告框与数据,只是获得JSON响应.....行被打印在屏幕上
这是我的返回声明:
return HttpResponse(simplejson.dumps(result) , content_type='application/json')
切勿在任何类型的回调中使用'document.write':它不应该在执行初始代码后执行。填写段落并将其附加到页面上(或在调试期间使用console.log)。 –
你能向我们展示你的观点吗?只是基于看jQuery的小剪辑,它应该工作。 –
答复在屏幕上打印为: [{“0”:“[email protected]”},{“1”:“[email protected]”},{“2”:“n @ n。 COM]}] 当我运行的HTML,它只是给出了获取JSON响应.....打印在它的空白页面。 – stark