PHP返回没有找到数据

时间:2015-02-18 16:40:58

标签: php jquery ajax

Php正在返回"没有找到数据"在ajax请求上。这是我的PHP代码和ajax调用。在网络部分php是请求没有显示。但是在控制台中出现错误,表示没有找到数据。请帮帮忙。

    <?php
    include 'dblinker.php';
    function getDetails(){
try {
        $link = linkToPoints();
        $handle = $link->prepare("SELECT * FROM leafly WHERE id < 11");
        $handle->execute();
        if(!($handle->rowCount())) {
                return "No data exists";
        }
        $result=$handle->fetchAll(\PDO::FETCH_OBJ);
        return json_encode($result);
    }
catch(Exception $e){
        return "Connection Error";
    }
}
echo getDetails();
?>

这是我的JS档案。

var timer;
$(document).ready(function(){
        fetchdata = function(){
                $.ajax({
                url: 'services/get_data.php',
                type: 'GET',
                success: function(json) {
                console.log(json)
                var json1 = jQuery.parseJSON(json);
                for(i=0; i < json1.length; i++)
                {
                    tr = $('<tr/>');
                    tr.append("<td>" + json1[i].id + "</td>");
                    tr.append("<td>" + json1[i].mod_name + "</td>");
                    tr.append("<td>" + json1[i].product_type_id + "</td>");
                    onemore=tr
                    $('#device_1').append(tr.clone());
                    $('#device_2').append(onemore.clone());
                }
                }
                });
        }
        fetchdata();
        $("#start").click(function() {
                timer = setInterval(function(){
                                $("#device_1,#device_2").find('tr').remove();
                                fetchdata();
                        },1000);
        });
        $("#stop").click(function() {
                clearInterval(timer);
        });
});

0 个答案:

没有答案
相关问题