我试图将我的JSON字符串转换为弹出窗口中的表格。我正在从网址中提取数据并立即将其显示在警报中。 json返回诸如名字,姓氏,地址等信息,我想将信息分类到表中。我将举例说明我现在正在使用的内容。
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseSearch">
<i class="fa fa-search" style="margin-right: 5px;"></i>Search
</a>
</h4>
</div>
<div id="collapseSearch" class="panel-collapse collapse">
<div id="tocContainer" class="panel-body panel-scroll">
<form>
<input placeholder="First Name" id="txtFirstName" type="text" name="fname"><br>
<br>
<input placeholder="Last Name" id="txtLastName" type="text" name="lname"><br>
<br>
<input type="button" value="Lookup" onclick = "lookUp();">
</form>
</div>
</div>
</div>
function lookUp() {
require(["dojo/request/xhr"
], function(
xhr
) {
var firstname = document.getElementById('txtFirstName').value;
var lastname = document.getElementById('txtLastName').value;
var url = "http:";
url += firstname + "/" + lastname;
xhr(url, {
handleAs: "json"
}).then(function(data){
alert(data);
}, function(err) {
alert('json error - ' + err);
}, function(evt) {
});
});