weixin_33744854 2013-10-30 02:57 采纳率: 0%
浏览 26

Ajax数据未加载

I am trying to code a simple customer mobile page. On the first page, i have names of each customer. onclick of one of them, it's open this file contain code below, however no data is loading. But if I try the refresh page, it works!


<script type='text/javascript' language='javascript'>
window.onload=function()
{

   url = 'http://whateverorigin.org/get?url=' + 
   encodeURIComponent('http://www.mydomain.com/myphpfile.php') + '&callback=?';
   $.ajax({
      url: url,
      dataType: 'json',
      timeout: 4000,
      success: function(reponse){
      a=reponse.contents.split(';'); 
      document.getElementById("client").innerHTML = a[0] ;
      document.getElementById("adresse1").innerHTML = a[1] ;
},

});

}

</script>
  • 写回答

1条回答 默认 最新

  • weixin_33705053 2013-10-30 03:03
    关注

    First off you dont need to include the '&callback=?'; param as jQuery will handle that automatically as long as you have dataType: 'JSONP'

    $(document).ready(function(){
        var encoded = encodeURIComponent('http://www.mydomain.com/myphpfile.php');
    
        $.ajax({
          url: 'http://whateverorigin.org/get?url='+encoded,
          dataType: 'jsonp',
          timeout: 4000
        }).done(function(reponse){
            //do your work 
        })
    })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答