【问题标题】:jquery .load does not seem to work for mejquery .load 似乎对我不起作用
【发布时间】:2016-05-02 14:34:40
【问题描述】:

尝试使用 jquery load() 函数,但似乎对我不起作用

$('#result').load('http://michaelschauffler.com/test.html', function(request, status, xhr){
     if (status == "error"){ // and it is
         // xhr.status is 0 and xhr.statusTest is error
         // then what is the error.
     }
});

这并不是我真正想要做的,但我似乎无法找出为什么事情似乎不像我找到的例子那样对我有用。 http://jsfiddle.net/webdevem/vxdHs/

所以我的目标页面上可能缺少一些东西。

【问题讨论】:

    标签: jquery get load


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      你忘了写 if 条件的右括号。

      请检查下面的代码。

       $(document).ready(function(){
      
       $('#result').load('http://michaelschauffler.com/test.html', function(request, status, xhr){
      
         if (status == "error"){ // and it is
           // xhr.status is 0 and xhr.statusTest is error
           // then what is the error.
         }
      
        });
      
      });
      

      【讨论】:

      • 仅在我的示例中。我更新了它。你有没有试过得到一些东西,因为我又不能。
      • 请检查上面的代码。如果您有任何错误,请告诉我。
      • 是的错误。我没有错过支架和/或准备好的文件。你看过我的评论吗?这是因为该站点未启用跨源请求
      猜你喜欢
      • 2011-01-14
      • 1970-01-01
      • 1970-01-01
      • 2011-03-13
      • 2016-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多