【问题标题】:JQuery AJAX Get data from database and feed it to HTML?JQuery AJAX 从数据库中获取数据并将其提供给 HTML?
【发布时间】:2014-04-18 06:58:04
【问题描述】:

我想使用数据库数据并使用 JQuery 的 AJAX 将其发送到 PHP 脚本。我将如何实现这一目标?

这是目前为止的代码:

function update(id) {
  $("#update").click(function() {
    $.ajax({
      type: 'POST',
      url: '<?= base_url("event/update_event_view"); ?>',
      data: {'id': id},
      dataType: 'json',
      success: function(retval) {
        $('#display').hide();
        $('#up').show();
        $('#up').html(retval[0]);
      }
    });
  });
}

【问题讨论】:

  • 我认为你走在正确的轨道上,这是正确的做法
  • 向我们展示您面临的问题或错误。
  • 这个问题已经回答了。 stackoverflow.com/questions/14776387/…
  • 你的php tag 中有错字。 &lt;?php base_url(); ?&gt;
  • @rockStar &lt;?=&lt;?php 的简写。

标签: jquery


【解决方案1】:

试试这个方法:

function update(id) {
      $.ajax({
          type: 'POST',
          url: "@Url.Action("update_event_view", "event")",
          data: {'id': id},
          dataType: 'json',
          success: function(retval) {
                 $('#display').hide();
                 $('#up').show();
                 $('#up').html(retval);
           }
      });
 }

【讨论】:

  • OP 需要在PHP 而不是.Net 中回答。
  • 感谢 rohan....现在如果我的脚本没问题,那么如何在表格的 html 页面中使用这些 retVal 数组???
猜你喜欢
  • 2016-02-12
  • 2013-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-12
  • 2018-09-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多