weixin_33744854 2017-10-13 09:34 采纳率: 0%
浏览 56

稳定的ajax加载php文件

I'm trying to use footable to display data from MySql.

Ajax load work well with .json files : Footable ajax doc

But when I tried to load data from php file, it didn't work, loader keep spinning.

My function :

    jQuery(function($){
        $('.table').footable({
            "rows": $.get('bdd/horaires/rows.php')
        });
    });

And my php file (for testing) :

<?php
$returnValue = json_encode('[{"id":1,"firstName":"Annemarie","lastName":"Bruening","something":1381105566987,"jobTitle":"Cloak Room Attendant","started":1367700388909,"dob":122365714987,"status":"Suspended"}]');
echo $returnValue;

I tried also json_decode but not working. I tried to simply output string without php line but not working too.

If someone can help me to output data from php, thank !

  • 写回答

2条回答 默认 最新

  • ?yb? 2017-10-13 09:37
    关注

    json is a string and the string you have is already valid json so you should not manipulate it by encoding it again:

    All you need is:

    <?php
    $returnValue = '[{"id":1,"firstName":"Annemarie","lastName":"Bruening","something":1381105566987,"jobTitle":"Cloak Room Attendant","started":1367700388909,"dob":122365714987,"status":"Suspended"}]';
    echo $returnValue;
    
    评论

报告相同问题?