使用 Ajax 为多用户应用程序加载整个 HTML


use ajax load the entire html for multiple user application?

如何将用户的数据从数据库加载到php再到ajax,然后操作DOM?

这是我的想法:

用户登录 ->使用 PHP 从数据库获取用户数据 -> ajax 使用 post 请求所有数据 ->在 DOM 上做某事

阿贾克斯是什么样子的?我只知道如何使用它来做从ajax到php到db:

$.ajax({
      type: "POST",
      url: "send.php",
      data: { item : text }
})

您可以在 send.php 中进行后端操作,然后您可以从后端返回 html 数据

例如。发送中.php

echo "<h2>" . $your_db_thing . "</h2>";

在 ajax 中,添加成功设置,参考 Jquery Ajax

$.ajax({
      type: "POST",
      url: "send.php",
      data: { item : text },
      success:function(data) { // data will be <h2>your_db_thing</h2>
            $('#successDiv').html(data); // the success element in which your html to be placed
      }
})