【问题标题】:Why jQuery does not run on my xampp on Mac?为什么 jQuery 不能在我的 Mac 上的 xampp 上运行?
【发布时间】:2021-06-20 10:16:06
【问题描述】:

<!DOCTYPE html>
<html>

   <head>
      <title>The jQuery AJAX Example</title>
      <script type = 'text/javascript' 
         src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
        
      <script type = 'text/javascript' language = 'javascript'>
         $.getJSON('https://api.flickr.com/services/feeds/photos_public.gne?tags=frenchay,uwe&tagmode=any&format=json&jsoncallback=?',
            function(data){
                $.each(data.items, function(i,item){
                  $('<img/>').attr('src', item.media.m).appendTo('#images');
                  if ( i == 10 ) return false;
               });
            });
      </script>
   </head>
    
   <body>
    
      <h3>Flickr (images tagged with uwe or frenchay)</h3>
        
      <div id = 'images'>
      </div>
        
   </body>
    
</html>

您好,我正在尝试运行此代码:

<!DOCTYPE html>
<html>

   <head>
      <title>The jQuery AJAX Example</title>
      <script type = 'text/javascript' 
         src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
        
      <script type = 'text/javascript' language = 'javascript'>
         $.getJSON('https://api.flickr.com/services/feeds/photos_public.gne?tags=frenchay,uwe&tagmode=any&format=json&jsoncallback=?',
            function(data){
                $.each(data.items, function(i,item){
                  $('<img/>').attr('src', item.media.m).appendTo('#images');
                  if ( i == 10 ) return false;
               });
            });
      </script>
   </head>
    
   <body>
    
      <h3>Flickr (images tagged with uwe or frenchay)</h3>
        
      <div id = 'images'>
      </div>
        
   </body>
    
</html>

如果我尝试在我自己的机器上用我的 mac 上的 xampp 运行它,它不会显示照片,就像我的笔记本电脑上缺少 jquery 一样。

代码在 jsfiddle 中运行。

【问题讨论】:

  • 确保您的 html 在 ="" 引用中没有空格。此代码在这里有效,您的计算机上出现什么错误?
  • 解决了你是对的。感谢您的帮助

标签: html jquery macos xampp


【解决方案1】:

对于未来的搜索,我在这里附上了解决的结果,收紧 = 和 "" 之间的空格为问题的原始海报修复了它:

<!DOCTYPE html>
<html>

   <head>
      <title>The jQuery AJAX Example</title>
      <script type='text/javascript' 
         src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
        
      <script type='text/javascript' language='javascript'>
         $.getJSON('https://api.flickr.com/services/feeds/photos_public.gne?tags=frenchay,uwe&tagmode=any&format=json&jsoncallback=?',
            function(data){
                $.each(data.items, function(i,item){
                  $('<img/>').attr('src', item.media.m).appendTo('#images');
                  if ( i == 10 ) return false;
               });
            });
      </script>
   </head>
    
   <body>
    
      <h3>Flickr (images tagged with uwe or frenchay)</h3>
        
      <div id='images'>
      </div>
        
   </body>
    
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多