首页 > 解决方案 > 返回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 的数组

标签: javascript

解决方案


  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);

推荐阅读