2010-01-20 2 views
0
내가 전달 도메인 http://whatthecatdragged.in/

의 모든 아약스 콘텐츠 로딩 http://moppy.co.uk/wtcdi/하나 개의 도메인

루트 페이지 (index.html을) 내용을로드 Ajax를 사용에 (은폐)하지 않습니다. 원래 호스트 (moppy.co.uk/wtcdi)에서 페이지와 모든 컨텐츠가로드됩니다. 그러나 도메인 전달 도메인 (whatthecatdragged.in)에서는 일부 콘텐츠가로드되지 않습니다. AnthonyWJones과 같이 Ajax 호출을 실행하는 데는 .each이 사용됩니다.

디버깅을 시도했지만 Firefox 3.5에서 콘솔 Firebug을 켜면 실제로 모든 콘텐츠가로드되는 것 같습니다.

 // Content building code: 
     $(function(){ 
      // Set a few variables (no need for secrecy with Flickr API key). 
      var apiKey = 'myapikey'; 
      // var tags = ''; 
      var tagsArr = new Array(); 
      // Get the photos of flickr user WhatTheCatDraggedIn. 
      // This Ajax call always seems to complete. 
      $.getJSON('http://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=' + 
        apiKey + 
        '&[email protected]&extras=date_taken,tags&format=json&jsoncallback=?', 
        function(data){ 

       // Set some variables to ensure alldata is fecthed from second API 
       // call (below) before building majority of content. 
       var totalExpected = data.photos.total; 
       var totalFetched = 0; 
       var photohtml = ''; 

       // For each photo, do the following: 
       $.each(data.photos.photo, function(i, item) { 
        // Set size of photo thumbnail to display. 
        var size = 's'; 
        var append = ''; 
        if (i == 0) { 
         // Display most recent thumbnail larger, and add a line 
         // break for small pics beneath it. 
         size = 'm'; 
         append = '<br />' 
        } 
        //Only display thmbnails of 4 most recent catches (1 large, 3 small). 
        if (i <= 3) { 
         var photoSrc = 
          'http://farm' + item.farm + '.static.flickr.com/' + 
          item.server + '/' + item.id + '_' + item.secret + '_' + 
          size + '.jpg' 
         //Each thumbnail links to that photo's Flickr page. 
         var flickrPage = 
          'http://flickr.com/photos/' + item.owner + 
          '/' + item.id + '/'; 
         // Each thumbnail has a big tooltip, with tags formatted appropriately. 
         var formattedTags = item.tags.replace(/\s/g, "<br />"); 
         formattedTags = formattedTags.replace(/cat/, "cat: "); 
         formattedTags = formattedTags.replace(/loc/, "location: "); 
         formattedTags = formattedTags.replace(/victim/, "victim: "); 
         formattedTags = formattedTags.replace(/status/, "status: "); 
         formattedTags = formattedTags.replace(/floor/, " floor"); 
         formattedTags = formattedTags.replace(/toy/, " toy"); 
         //Append the built html to one varable for adding to page shortly 
         photohtml += 
          '<a class="flickr-page-link" href="' + 
          flickrPage + '"><img src = "' + 
          photoSrc + '" title="' + formattedTags + '"/>' + 
          append + '</a>'; 
        } 

        var photoID = item.id; 
        // Get the detailed photo information (including tags) for the photo. 
        // This is the call that perhaps fails or at least content 
        // generated after this call does not load. 
        $.getJSON(
          'http://api.flickr.com/services/rest/?&method=flickr.photos.getInfo&api_key=' + 
          apiKey + '&photo_id=' + photoID + 
          '&format=json&jsoncallback=?', function(data){ 
         if (data.photo.tags.tag != '') { 
          $.each(data.photo.tags.tag, function(j, item) { 
           // Place all tags in an aray for easier handling. 
           tagsArr.push(item.raw); 
          }); 
          // Incrememt number of photos fetched. 
          totalFetched += 1; 
          // Have we got them all? 
          if (totalFetched == totalExpected) 
           fetchComplete(); 
         } 
        }); 
        // Builds a shedload more content once all JSON calls are completed. 
        function fetchComplete() 
        { 
         // ### BUILD VICTIM list ### 
         // format a regex to match tags beginnign : "victim: " 
         var vicRe = /^v[a-z]+:\s([a-z\s]+)/ 
         // Match the regex to the tags and count number of matches per tag. 
         var vicCounts = tagsArr.countVals(vicRe); 
         var victimsHtml = ""; 

         // For each victim. 
         for (var i in vicCounts) { 
          var strippedTag = [i].toString().replace(/\W/g, ""); 
          console.debug(strippedTag); 
          // Add a line of html with the type of victim and the number of victims of that type 
          victimsHtml += 
           "<a href='http://flickr.com/photos/[email protected]/tags/victim" + 
           strippedTag +"/'>" + [i] + 
           " (" + vicCounts[i] + ") </a><br />"; 
         }; 
         // Replace existing HTML with new version. 
         $('#types-dragged').html(victimsHtml); 

         // ### BUILD STATUS PIE CHART ### 
         // Build a theme for chart colours. 
         var wtcdicharttheme= { 
          colors: ['#C66800', '#D3C70B', '#DD3D0B', '#D30729', 
            '#DDA70B'], 
          marker_color: '#000000', 
          font_color: '#000000', 
          background_colors: ['#ffffff', '#ffffff'] 
         }; 

         // Create a new chart object, include css id of canvas 
         // where chart will be drawn. 
         var g = new Bluff.Pie('status', '275x250'); 
         // Set a theme and stuff. 
         g.set_theme(wtcdicharttheme); 
         // No title, as this exists via the raw page HTML. 
         g.title = ''; 
         g.legend_font_size = "50px"; 
         g.marker_font_size = "20px"; 

         // Build a regex string to match tags beginning "status: ". 
         var statRe = /^s[a-z]+:\s([a-z\s]+)/ 
         // Match regex to tags and return an object with tag 
         // names and number of occurences. 
         var statCounts = tagsArr.countVals(statRe); 

         // For each status. 
         for (var i in statCounts) { 
          // Add data to the chart 
          g.data([i], [statCounts[i]]); 
         }; 
         // Draw the chart. 
         g.draw(); 

         // ### BUILD LOCATION LIST ### 
         // Build a regex that matches tags beginning "loc: " 
         var locRe = /^l[a-z]+:\s([a-z\s]+)/ 
         // Match regex to tags and return an object with 
         // tag names and number of occurences. 
         var locCounts = tagsArr.countVals(locRe); 
         var locatHtml = ""; 

         // For each location. 
         for (var i in locCounts) { 
          var strippedTag = [i].toString().replace(/\W/g, ""); 
          // Add a line of html with the location and the 
          //number of times victims found in that location. 
          locatHtml += 
           "<a href='http://flickr.com/photos/[email protected]/tags/loc" + 
           strippedTag +"/'>" + [i] + " (" + 
           locCounts[i] + ") <br />"; 
         }; 
         // Replace existing html with newly built information. 
         $('#locations').html(locatHtml); 

         // ### BUILD CAT LIST ### 
         // Build a regex that maches tags beginning "cat: ". 
         var catRe = /^c[a-z]+:\s([a-z_\s]+)/ 
         //Match regex to find number of catches each cat has made 
         var catCounts = tagsArr.countVals(catRe); 

         // For each cat. 
         for (var i in catCounts) { 
          var strippedTag = [i].toString().replace(/\W/g, ""); 
          // Insert number of catches to div titled "(catname)-catch" 
          $('#'+ [i] + '-catch').html(
           "<a href='http://flickr.com/photos/[email protected]/tags/" + 
           strippedTag + "/'>" + catCounts[i] + "</a>"); 
         }; 
        } 
       }); 
       // Insert total dragged onto page. 
       $('#total-dragged').html(data.photos.total); 
       // Insert photos onto page. 
       $('#latest-catches').html(photohtml); 
       // Add tooltips to the images from Flickr. 
       $('img').each(function() { 
        $(this).qtip({ 
         style: { 
          name: 'wtcdin' 
         }, 
         position: { 
          target: 'mouse', 
          adjust: { 
           x: 8, 
           y: 10 
          } 
         } 
        }) 
       }); 
      }); 
     }); 

UPDATE 1 : 나는 그들의 조언 "JavaScript를 사용하지 않는"기본적으로했다, 도메인 이름의 회사를 연락했다. 아직도 그것이 하나의 도메인 이름과 다른 도메인 이름에서 작동하지 않는 이유를 알 수 없습니다 ... 그들이 프레임을 통해 도메인을 "전달"한다는 사실과 관련이있을 수 있습니까?

+0

두 개의 링크와 '끌어온 항목의 유형', '발견 된 위치 항목'및 '항목 상태'가 모두로드되지 않습니다 ... –

+0

예, 이전에 같은 세션 내에서 있었던 것 같습니다. 탭에서 firebug를 활성화 시켰습니다. moppy.co.uk에서 버전을보고있었습니다. 내 실수. – fearoffours

답변

2

브라우저는 스크립트가 호스팅되는 도메인 외부로 전송 된 AJAX 요청을 차단합니다. 이것은 사물의 소리로 인한 문제의 원인 일 가능성이 큽니다.

편집 : 문제가 발견되었습니다. 스크립트에 console.debug() 호출이 있습니다. 이 방법은 Firebug Console에 의해 정의되어 콘솔이 활성화되어있는 동안에 만 작동합니다. console.debug()에 대한 호출을 제거하고 이것이 어떻게되는지보십시오.

+0

나는 링크를 따라 소스를 확인하고 포워딩이 그가 프레임을 사용하고 있다는 것을 의미 할 때 그가 무엇을 의미하는지. 프레임의 내용 ('

관련 문제