AJAX / PHP显示错误"成功":未捕获TypeError:undefined不是函数

时间:2015-03-20 17:47:25

标签: php ajax lightbox

我需要帮助。我构建了一个“搜索”表单来搜索数据库并通过AJAX发送它。问题是,内容已经传递,结果也显示在请求中的Google Chrome Web Develeloper工具中 - >预览,但不在屏幕上。结果到了。

但是当我想在屏幕上用灯箱显示结果时出现错误:http://i.stack.imgur.com/IBmZ4.png

我的代码, jQuery POST AJAX

function submitDetailsForm() {
 $('#searchit').submit(function() {
        var content = $("#searchit_input").val();
        var dataString = 'content='+ content;
        if(content == '') { alert("Nothing here."); } else {
            $.ajax({
            type: "POST",
            url: "/ajax/search.php",
            data: dataString,
            cache: false,
            success: function(result){
             $.lightbox("/ajax/search.php", {
    'width'       : 610,
    'height'      : 458,
    'autoresize'  : true
  });;
            }

            });
            }       
        return false;   
    });
}

的search.php

<?php
$Results = $connection->query("SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_title LIKE '%$content%' AND keywords LIKE '%$content%' AND topstory != '' ORDER BY post_modified DESC LIMIT 8"); 
    if (mysqli_num_rows($Results) < 1) {    

        echo "Nothing found.."; 
    } else {


        while($Show = $Results->fetch_object()) {
        $Title =  $Show->post_title; 
        $Topstory = $Show->topstory;
        $Description = $Show->longdesc;
        $id = $Show->ID;




?>
hi
<?php
        }
    }
?>

提前谢谢你。 :)

1 个答案:

答案 0 :(得分:0)

您没有在灯光屏幕上显示result。您根本没有使用result。可能性就是您的问题所在。

$.ajax({
    type: "POST",
    url: "/ajax/search.php",
    data: dataString,
    cache: false,
    success: function(result) {
        // you need to actually do something with `result` in here to
        // actually use the result of your ajax call.
    }
});

你没有指出你正在使用哪个灯箱插件,所以我不知道它应该如何工作,但是你可以把它设置成你想做的事情,这是一个公平的赌注。