php - AJAX 调用后使用 jquery 刷新 DOM

标签 php javascript jquery ajax fancybox

我正在开发一个新项目 http://www.hotwirerevealed.com它显示/识别 hotwire.com 上的酒店。输入状态和目的地后,我有一个 javascript 函数,它使用 jquery 的 .post 方法进行发布。 post请求转到输出html的php页面,我使用jquery的html方法将内容放置在页面上。

像这样

function post(){
    $.post("lookup.php", {action: "find", area: area, stars: stars, amenities: amenities, state: $('#state').val()}, function(data){ 
        $("#details").html(data);
    });
}

我有一些酒店的超链接,我喜欢在灯箱中使用这些链接

<a class="hotel" href="http://google.com/search?btnI=1&amp;q=Amerisuites+Northeast+Orlando+(Airport+MCO)">Amerisuites Northeast</a>

我正在尝试使用jquery的花式框,但是花式框

$(document).ready(function(){
    $(".hotel").fancybox({
        'width'             : '75%',
        'height'            : '75%',
        'type'              : 'iframe'
    });
});

但它似乎不起作用,我猜是因为 jquery 不知道它在那里的元素?我尝试使用 jquery live() 方法但收效甚微,任何帮助将不胜感激,提前致谢

最佳答案

最快的方法是添加 livequery plugin到页面,
然后代替你的:

$(document).ready(function(){
  $(".hotel").fancybox({
        'width'             : '75%',
        'height'            : '75%',
        'type'              : 'iframe'
  });
});

这样做:

$(document).ready(function(){
  $(".hotel").livequery(function(){
    $(this).fancybox({
        'width'             : '75%',
        'height'            : '75%',
        'type'              : 'iframe'
      });
  });
});

关于php - AJAX 调用后使用 jquery 刷新 DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2660736/

相关文章:

php - 使用 PHP 将 Android 应用程序连接到外部 MySQL 数据库

javascript - 在 CSS 和 JS 中动态调整高度

javascript - 对d3js条形图进行排序

php - MySQL 文件下载速度限制

php - Laravel - 如何创建数据库表

JQuery 错误 : XML filter is applied to non-XML value (function (E, F) {return new (o.fn.init)(E, F);})

javascript - jQuery - 这个时间线是如何制作的?

php - 如何从 MySQL 中的表的列中获取特定项目并使用它来使另一个 <select> 更改其可见性

php - 现有项目的 Laravel 管理面板

javascript - 历史敏感后退按钮