【问题标题】:How to map json response to UI in javascript如何在javascript中将json响应映射到UI
【发布时间】:2018-06-05 20:57:41
【问题描述】:
SERVICES.startconference(meet.value, participants, function(res) {

Log.d("div", "getting success response and posting to new tab", res&& res.OUTERHTML);

.....

}

【问题讨论】:

  • 为您的问题添加更多详细信息。
  • 有来自 api 的响应,其中包含会议名称、访问代码、会议 ID、日期和时间以及参与者。我需要在会议开始时在运行时动态显示这些详细信息。如何相应地制作 UI?
  • 编辑您的问题并将其添加到那里
  • 我可以看到你是 stackoverflow 的新手。确保学习如何使用本网站。看一眼stackoverflow.com/tour
  • 如果我的回答符合你的问题,请标记为回答

标签: javascript html json api


【解决方案1】:

这里有一些你可以使用的代码:

    <script>
    let use_api = function(){
        req = new XMLHttpRequest()
        req.setRequestHeader("Content-type", "application/json");
        req.onreadystatechange = function(){
            if(req.readyState == 4 && req.status==200){
               let data = JSON.parse(xhr.responseText);
               //here you should update your UI with the received data!  
            }
        }
        let req_body = JSON.stringfy({"username":"asdfasdf"}) //username is just an example, you should write things you want to send to API endpoint
        req.open('POST',url,true)
        req.send(req_body)

    }
</script>

也看看this
祝你好运。

【讨论】:

    猜你喜欢
    • 2014-04-12
    • 2020-12-07
    • 2020-09-13
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    • 2018-08-20
    相关资源
    最近更新 更多