javascript - 返回ajax数组后的每个javascript
问题描述
我的函数 javascript
setInterval(function(){
jQuery.post("item.php?ac=show",
{}, function(data)
{
$.each(data, function(index, value) {
console.log(value);
});
});
}, 10000);
我的回报 php
Array
(
[10] => Pago
[12] => Pago
)
我需要通过每个读取来自 javascript 中 php 的数组
解决方案
function getData() {
$.ajax({
url: "item.php?ac=show",
type: "get",
dataType: 'json',
success: function (data) {
$.each(data, function (index, value) {
console.log(value);
});
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}
setInterval(getData, 10000);
推荐阅读
- arrays - Ruby - 仅打印哈希数组中重复哈希键的值
- mysql - 如何在mysql中索引动态生成的嵌套JSON列
- html - 在密码输入元素内放置屏蔽/取消屏蔽按钮
- ruby-on-rails - Rails在多对多关系中统一了常量错误
- sql - 在子查询中选择 2 小时之间的最短时间
- mysql - MySQL 如果字段等于 X 则显示为 Y
- android - 如何在多个 LatLong Android 地图之间绘制路线?
- javascript - 使用 CSS 创建平滑的粘性标题过渡
- vb.net - 通过 VB.NET 使用 Rar.exe 压缩文件夹?
- android - 如何在 webview 中使用相机反应原生?