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;
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元