输出缓冲和php页面和ajax

时间:2015-03-17 16:04:08

标签: php jquery

我有一个php页面,我想用ajax获取输出的html。这是我的ajax代码。

<script>
$(function() {
    $(".load_product_gallery").on("click",function () {
         $.ajax({
        url: 'product_gallery_popup.php', // The source
        cache: false, // Make sure results are not cached
        success: function (data) {
            $('.product_gallery_popup_container_2').html(data); 
        }
    });

    });


});

</script>

data应该是php页面的输出html。

我的php页面:

     ob_start(); // begin buffering content

  /* php page content */

  $html = ob_get_clean();  // grab buffered content and stop buffering
  return $html;

这会将php页面输出的内容以html格式返回给ajax吗?

0 个答案:

没有答案