简体   繁体   English

使用JavaScript读取uClassify URL呈现的JSON数据

[英]Reading JSON data presented by uClassify url using JavaScript

I am a noob and I need help in a project. 我是菜鸟,我需要一个项目的帮助。 This is the API URL provided by the uClassify site, https://api.uclassify.com/v1/uclassify/sentiment/classify/?readKey=YOUR_READ_API_KEY_HERE&text=This+is+the+text+to+classify 这是uClassify网站提供的API URL,网址为https://api.uclassify.com/v1/uclassify/sentiment/classify/?readKey=YOUR_READ_API_KEY_HERE&text=This+is+the+text+to+classify

the JSON data is displayed as {"negative":0.0778055,"positive":0.922195} JSON数据显示为{“负”:0.0778055,“正”:0.922195}

Can someone please suggest a code in javascript to read the JSON data and store in a variable? 有人可以在JavaScript中建议一个代码来读取JSON数据并存储在变量中吗?

refer the following: 请参考以下内容:

$("#ddlButton").click(function () {

 $.getJSON("https://api.uclassify.com/v1/uclassify/sentiment/classify/", { readKey: YOUR_READ_API_KEY_HERE,text=This+is+the+text+to+classify},
           function (data) {

               $.each(data, function (Modal, itemData) {


                       document.getElementById("text1").text= itemData.negative,
                       document.getElementById("text2").text= itemData.positive

               });
           });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM