如何从 Parse 数据库中检索数据并显示在 html 中

how to retrieve data from Parse database and display in html

我正在尝试检索通过其他网站发送到数据库的数据。我正在使用搜索栏查询地址,一旦成功,我想在搜索栏下方的页面上显示该行中的其余对象。我在使用显示对象参数的语法时遇到了问题。

javascript:

Parse.initialize('###########');
databaseURI = 'mongodb://############';
var aptQuery = new Parse.Query(Apartment.address)
aptQuery.find({
  success:function(foundApts){
    console.log(foundApts);
  }, error: function(error){
    console.log(error);
  }
})
console.log(savedApartment);

html:

    <input type="search" id="aptSearch" placeholder="Address" >

要从您的对象中获取一个字段,您可以这样写:

appartement.get("city");

要在您的 HTML 代码中进行设置:

document.getElementById('aptSearch').value = appartement.get("city");

所以你的代码可以是这样的:

var aptQuery = new Parse.Query("Apartment")
aptQuery.find({
  success:function(foundApts){
    console.log(foundApts);
    for (var i in foundApts) {
        var appartement = foundApts[I];
        document.getElementById('aptSearch').value = appartement.get("city");
    }
  }, error: function(error){
    console.log(error);
  }
})