数据库ajax​​从php页面调用

时间:2015-09-21 02:36:28

标签: jquery ajax datatables

我试图将json从我的php页面加载到带有以下js的Datatable中:

var path = Path.GetDirectoryName(typeof(UserControl1).Assembly.CodeBase);

json并没有出现在Datatable中,而是我看到的所有内容都是"正在加载......"

当我从我的php页面复制json有效负载并保存到txt doc并调用该doc而不是json在Datatable中显示没有问题时:

$(document).ready(function() {
    $('#detailed').DataTable({
        "ajax": {
            "url": "myphpPage.php",
            "dataSrc": "data"
        },
        "columns": [{
            data: "SEG_CODE"
        }, {
            data: "START_MOMENT"
        }, {
            data: "STOP_MOMENT"
        }]
    });
});

这是我的json数组:

$('#detailed').DataTable({
    "ajax": {
        "url": "detailed.txt",
        "dataSrc": "data"
    },
    "columns": [{
        data: "SEG_CODE"
    }, {
        data: "START_MOMENT"
    }, {
        data: "STOP_MOMENT"
    }]
});

有没有理由从我的php页面中数据表在加载时卡住而不是txt doc?

提前致谢。

1 个答案:

答案 0 :(得分:0)

@daremachine,谢谢,我输入了完整的网址,而不是亲戚。

改变:

<ul id="listings">
  <li><input type="text" id="adjectives1" value="Adjective" onchange="update(this)"></li>
  <li><input type="text" id="adjectives2" value="Adjective" onchange="update(this)"></li>
  <li><input type="text" id="adjectives3" value="Adjective" onchange="update(this)"></li>
</ul>


<div id="textualdiv"> As the <span id="adjective1">fatal</span> mating dance of a pair of black holes with a total mass of more than a billion suns. Mostly in the form of <span id="adjective2">violent</span> <span id="noun3">ripples</span> in space-time known as  <span id="adjective3">gravitational</span> waves.</div>

为:

"url": "www.mysite/myphpPage.php",