为什么这个JQuery Ajax调用无法在PhoneGap中运行

时间:2011-08-13 15:22:07

标签: ajax jquery-mobile cordova

我正在使用PhoneGap和JQuery mobile ajax从数据库中检索一些记录,这是我的代码!!但不幸的是它不起作用 谁能告诉我什么是错的

<script>
$(document).ready(function() {
            $('#cont').bind('pageshow', function () {
                       $.get('http://tech-tude.com/freedomwobas/getepisodes.php', function (data) {
                     $(this).find('div[data-role="content"]').append(data);
                 });
                    });
                    });

</script></head><body ><div data-role="content"></div>     

1 个答案:

答案 0 :(得分:1)

您需要(至少)等待设备准备就绪。试试这个:

<script>
function onDeviceReady() {
    $('#cont').bind('pageshow', function () {
        $.get('http://tech-tude.com/freedomwobas/getepisodes.php', function (data) {
      $(this).find('div[data-role="content"]').append(data);
  });
     });
}
$(document).ready(function() {
    document.addEventListener("deviceready", onDeviceReady, true);       
});
</script></head><body ><div data-role="content"></div> 
相关问题