我的AJAX请求是这样的-
$.ajax({
type: "POST",
url: "ajax/feed-check.php",
dataType: "json",
data: {
server: server,
},
complete: function(data) {
console.log(data);
$('.Agencies').html('<p>'+data[0]+'</p>');
}
})
上面的返回和数组如下所示
[{"feed_name":"example.zip","feed_time":"2015-10-16 00:00:24","feed_size":"1222","back_office"
:"example4","agencyID":"example2"},{"feed_name":"example2.zip","feed_time":"2015-10-16 08:20:00","feed_size"
:"3145","back_office":"example1","agencyID":"aaa"}]
"
在AJAX请求中完成功能后,如何获取数据?我正在尝试这样做
complete: function(data) {
$('.Agencies').html('<p>'+data[0]+'</p>');
}
但是我变得不确定,有人可以告诉我我要去哪里了吗?我需要取出所有数据。
我的PHP脚本-
$whereArray = array(
"$where",
"=",
$_POST['server'],
);
$andArray = array(); //- Blank 'AND' array so that the 'get' call below doesn't fail if no 'ANDs' are passed.
$orArray = array(); //- Blank 'OR' array so that the 'get' call below doesn't fail if no 'ORs' are passed.
$order = array();
$agencyfeed = paddyDB::getInstance("paddy_ms")->get('feed_files', $whereArray, $andArray, $orArray, $order);
//print_r ($agencyfeed->results());
$feeds = [];
foreach ($agencyfeed->results() as $key) {
$feeds[] = $key;
//$key = $feeds['feed_name'];
}
echo json_encode($feeds);
看着错误的文件,derp。已用相关详细信息更新了帖子
谢谢。
参考方案
尝试这个:
complete: function(data) {
$.each(data, function(i, member)
{
$(".Agencies").html('<p>'+data[i].feed_name+'</p>');
})
}
PHP:将数组值加在一起 - php我相信这比标题听起来要难一些,但我可能完全错了。我有一个像这样的数组:[["londrina",15],["cascavel",34],["londrina",23],['tiradentes',34],['tiradentes',21]] 我希望能够采用通用…
PHP JQuery复选框 - php我有以下片段。 var myData = { video: $("input[name='video[]']:checked").serialize(), sinopse: $("#sinopse").val(), dia: $("#dia").val(), quem: $(…
如何从php中获取datatables jQuery插件的json数据 - php我是PHP的新手,正在尝试使用Datatables jQuery插件。我知道我必须从.php文件中获取数据,然后在数据表中使用它,但是我似乎无法通过ajax将其传递给数据表。我设法从数据库中获取数据,并对其进行json编码,但是后来我不知道如何在我的index.php文件中调用它,并在其中显示它。我究竟做错了什么?这是我的代码:HTML(已编辑): <…
PHP-正则表达式删除引号并添加大括号? - php好吧,我不愿承认这一点,但是我对REGEX感到很困难,我永远找不到关于如何设置表达式的不错的教程。所以说我有这样的事情context['something'] 我想将所有事件更改为context[something] 那我有' . $var . ' 我想将所有事件更改为{var} 这是当前的概念,但是我在正则表达式部分…
PHP:获取调用引用的数组名称 - php假定以下函数并调用:function doSomething( &$someArray ) { // Do something to $someArray } $names=array("John", "Paul", "George", "Ringo"); doSomet…