dsgdg46465 2017-04-03 16:59
浏览 63

Javascript没有加载mysql数据phonegap

I have a website written in HTML/Javascript and I use jquery to load data from MYSQL by calling php files. The website is working. I am trying to phonegap the same website but the data from MySQL is not loading. I am not using localhost in the database connect. Is there something wrong with my jquery?

<!-- Ajax for JSON -->
<script src="dist/js/jquery-1.12.4.min.js"></script>

<div id="featured_items" class="streamline message-box message-nicescroll-bar">
    <script type='text/javascript'>
       $(document).ready(function () {
          /* call the php that has the php array which is json_encoded */
          $.getJSON('php/items.php', function (get_items) {
          /* data will hold the php array as a javascript object */
          $.each(get_items, function (get_items_key, get_items_val) {
             $("#featured_items").append(
                '//HTML Code Here'
             );
          });
       });
    });
    </script>
</div>
  • 写回答

1条回答 默认 最新

  • doutang0335 2017-04-04 13:04
    关注

    Try to get data like this

    var table_data = $.parseJSON($.ajax({
        type: "post",
    url: SITE_URL,
    dataType: "json",
        async: false
    }).responseText);
    

    then run following code

    $.each(table_data, function(index, item) { })
    

    Hope it is work for you

    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用