jQuery从php json_encode获取数组 [英] jQuery getting array from php json_encode
本文介绍了jQuery从php json_encode获取数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在php中创建了一个数组。我只想在jquery中获取数据
I created an array in php. I simply want to get the data it in jquery
这是support.php中的数组:
here is the array in support.php:
$postData = array(
"error" => $error,
"successInfo" => $successInfo,
"email" => $_POST["email"],
"subject" => $_POST["subject"],
"description" => $_POST["description"],
);
echo json_encode($postData);
我在javascript方面使用jquery.getJSON做什么?
What shall I do in javascript side using jquery.getJSON?
提前致谢!
推荐答案
您可以通过这种方式访问数组
You can access an array in this way
$.ajax({
type: 'POST',
url: 'support.php',
success: function(result) {
$('#content1').html(result[0]);
},
});
这篇关于jQuery从php json_encode获取数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文