javascript - 使用 jquery getjson 检索 JSON 提要?

标签 javascript jquery json ajax getjson

我已经玩这段代码太久了,没有解决方案。

它指向的 url 包含这个(json 对象):

{ "description": "Input 1", "type": "no", "enabled": true, "alarm": false }

$(document).ready(function () {
        var data;
        $.ajax({
            dataType: "json",
            url: 'http://192.168.1.2/alarm.cgi',
            data: data,
            success: function (data) {
                // begin accessing JSON data here
                console.log(description);
            }
        });
    });

既然是描述,这不应该返回“输入 1”吗?

最佳答案

data的值是整个对象,需要访问description属性,所以应该是console.log(data.description);

关于javascript - 使用 jquery getjson 检索 JSON 提要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49634756/

相关文章:

javascript - 如何在javascript中使用自己的属性值

javascript - 将自定义下拉菜单/按钮添加到 Redactor WYSIWYG

asp.net - 在 ASP.NET 表单字段模糊时,调用该字段上的验证器

jquery - 使用 jQuery 计算字符数

javascript - 通过 AJAX 拉入 JSON 以填充下拉列表

javascript - React-native-camera 没有出现在屏幕上

javascript - 使用链接在div内滚动div?

javascript - fullPage.js 菜单没有像示例中那样出现

c# - 向不记名 token json 添加更多值

json - 使用 Observable 在 Angular 2 中发出轮询请求