Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 变量检索JSON_Javascript_Json - Fatal编程技术网

Javascript 变量检索JSON

Javascript 变量检索JSON,javascript,json,Javascript,Json,我有下一个objet jSon: {prtg版本:14.3.10.2422,treesize:3700,:[{objid:0,probe:,probe_raw:}] 我需要参数来objid和prove以及下一个程序javascript: $(document).ready(function() { /* call the php that has the php array which is json_encoded */ functi

我有下一个objet jSon:


{prtg版本:14.3.10.2422,treesize:3700,:[{objid:0,probe:,probe_raw:}]

我需要参数来objid和prove以及下一个程序javascript:

    $(document).ready(function()
    {
            /* call the php that has the php array which is json_encoded */
          function act()
        {
            $.getJSON('https://10.213.8.25/api/table.json?columns=objid', function(data) {
                    /* data will hold the php array as a javascript object */
                    $.each(data, function(key, val) {


                              $.each(data, function(key, val) {
                            $('ul').append('<li id="' + key + '">' + val.objid +' </li>');

                    });

                    });
            });


        }
        setInterval(act, 1000);
    });
如果modifique my jSon all ok:

[{objid:0,probe:,probe_raw:}]

但是URL与之前的jSon和我的程序javascrip一起工作,不起作用。你能帮我对错误进行评论吗


谢谢!

给定以下JSON:

{
    "prtg-version":"14.3.10.2422",
    "treesize":3700,
    "":[{"objid":0,"probe":"","probe_raw":""}]
}
。。。我首先要指出,将空字符串作为JSON键是非常不寻常的。话虽如此,如果你愿意,你可以这样做。但是,如果要迭代这些值,则需要替换:

$.each(data, function(key, val) {
。。。为此:

$.each(data[""], function(key, val) {

我仍然有问题,我已经在PHP和调用控制中武装了JSON对象,它可以工作,但是通过更改应该获取信息的URL地址不会给我带来任何东西,如果我做了任何更改,你知道吗

 $(document).ready(function()
    {
            /* call the php that has the php array which is json_encoded */
          function act()
        {
            $.getJSON("https://10.213.8.25/api/table.json?&content=sensors&output=json&columns=objid&count=1&username=prtgadmin&password=SIEoperaciones01", function(data) {
            //$.getJSON('DMS_PRTG_prueba.php', function(data) { ***OK***

                    /* data will hold the php array as a javascript object */
                    $.each(data, function(key, val) {
                            $('ul').append('<li id="' + key + '">' + val.objid +' </li>');

                    });
            });


        }
        setInterval(act, 1000);
    });

{prtg version:14.3.10.2422,treesize:3188,sensors:[{objid:1001}}}

看起来您应该能够使用数据[]访问阵列。不过我会使用一个更好的键。{prtg版本:14.3.10.2422,treesize:3188,sensors:[{objid:1001}}},函数是$.eachdata[sensors],functionkey,val{$'ul'。append+val.objid+'';但不起作用