duanhemou9834 2012-09-25 16:20
浏览 86
已采纳

$(window).load()里面有ajax

I'm trying to retrieve all the data inside the database when the page is loaded but when I try to click the refresh button nothing was returned, do you have any idea why? Here is my code:

      $(window).load(function (){
        $.ajax({                
            url: 'get.php',
            dataType: 'json',
            success: function (data){
               $.each(data, function(i,item) {
                 $('#info').append("<p> you are:"+data[i].username+"</p> <p> your  message  is:"+data[i].msg);
               })
             }
        });


      });
  • 写回答

2条回答 默认 最新

  • dongshi1914 2012-09-25 18:09
    关注

    New answer posted here.

    Change your php code as below

    if(isset($_POST['username']) && isset($_POST['msg'])){
      $username = $_POST['username'];
    
      $msg = $_POST['msg'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)