Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQueryMobile-JSON请求_Jquery_Html_Json - Fatal编程技术网

jQueryMobile-JSON请求

jQueryMobile-JSON请求,jquery,html,json,Jquery,Html,Json,我正在努力让我的$.getJSON在jQuery mobile中启动。我试着在jQuery加载之后和jQueryMobile之前调用它,但都没有用。一开始我还尝试了不同的功能,如: $(document).ready $(document).bind("mobileinit" 等等 这是我的。第一个警报会运行,但当它到达JSON部分时似乎会停止 $(document).bind("mobileinit", function(){ $('#home_screen').live('pag

我正在努力让我的$.getJSON在jQuery mobile中启动。我试着在jQuery加载之后和jQueryMobile之前调用它,但都没有用。一开始我还尝试了不同的功能,如:

$(document).ready
$(document).bind("mobileinit"
等等

这是我的。第一个警报会运行,但当它到达JSON部分时似乎会停止

$(document).bind("mobileinit", function(){

    $('#home_screen').live('pagecreate',function(event) {

        alert('Loaded'); // Runs fine

        $.getJSON('includes/data/get.php',{'request_type':'count'}, function(data) {
            $.each(data, function(i, item) {
                alert(2);
            });
        });
    });

});

尝试使用jQuery.ajax(然后使用jQuery.parseJSON)而不是$.getJSON,这样您就可以通过设置错误回调来调试正在发生的事情。

firebug怎么说?有错误吗?你能试着把这条路当作绝对路径吗
/includes/data/get.php
它在Firefox中运行得非常好。当我把它加载到我的iPhone上时,它就不起作用了。我在JSON内容之后添加了另一个警报,它似乎完全跳过了JSON部分。很抱歉回复太晚。我已经尝试将其更改为$.ajax,但仍然没有任何效果。对下一步做什么有什么建议吗?您可能认为在jQueryMobile上这样做很容易。您是否尝试过设置相对于根文件夹的路径?“/relative/to/the/root/folder”而不是“relative/to/current/folder”