如何在Ajax成功函数中提醒php数组 [英] How to alert a php array in ajax success function
问题描述
我知道这个问题很难回答,但是我无法通过堆栈溢出或谷歌搜索找到许多问题的正确答案.因此,我无奈地把这个问题放在了这里.
I know that this question is so simple to ask, but I wasn't able to find the right answer for it, by going through many questions on stack overflow or by googling. So I found noway but to place the question here.
我有一个mysql表,如下所示:
I have a mysql table as follow:
[0]1>>>>2>>>>>3>>>>>5>>>>>6
[1]1>>>>2>>>>>3>>>>>5>>>>>6
[2]1>>>>2>>>>>3>>>>>5>>>>>6
[3]1>>>>2>>>>>3>>>>>5>>>>>6
[4]1>>>>2>>>>>3>>>>>5>>>>>6
[5]1>>>>2>>>>>3>>>>>5>>>>>6
我需要将其存储在变量中,并用json解析回ajax函数,但是得到的结果是[object Object],[object Object],[object Object],[object Object],[object对象],[对象对象],[对象对象],
I need to store it in a variable and parse it with json back to the ajax function, but the result I get is [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
这是php代码:
$ent = $_POST['id'];
$column = array();
$gtord = mysql_query("SELECT * FROM order WHERE oId = '$ent' ");
while($rowmnu2=mysql_fetch_assoc($gtord))
{
$column[] = array($rowmnu2);
}
echo json_encode($column);
这是ajax函数:
$.ajax({
type: 'POST',
url: "profile/ajax/getorder.php",
data: {id:gotid},
dataType: 'json',
cache: false,
success: function(result) {
alert(result);
},
});
我确定我的ajax代码成功警报中有一个错误,但是我无法弄清楚如何遍历接收到的数组.
I am sure that there is an error in my ajax code success alert, but I am not able to figure it out, how to go through the received array.
请帮助我.预先赞赏.
Please help me. Appreciated in advance.
推荐答案
尝试:
alert(JSON.stringify(result));
这篇关于如何在Ajax成功函数中提醒php数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!