2013-03-18 30 views
-1

我想將jsfiddle創建轉移到我的網站,但我無法這樣做。這裏是鏈接到它:無法將jsfiddle創建轉移到網站

http://jsfiddle.net/mDc7p/213/

/* 
    Eventbrite Examples - organizer event list 

    If you copy this code, please set your own API Key in the example below. 
    You can request one here: http://www.eventbrite.com/api/key 
*/ 

Eventbrite({'app_key': "HSMTSI2CUDKAXFTXX2"}, function(eb){ 

    // define a few parameters to pass to the API 
    // Options are listed here: http://developer.eventbrite.com/doc/organizers/organizer_list_events/ 
    var options = { 
     'id' : "1667880002" 
    }; 

    // provide a callback to display the response data: 
    eb.organizer_list_events(options, function(response){ 
     $('.event_list').html(eb.utils.eventList(response, eb.utils.eventListRow)); 
    }); 
}); 

我曾嘗試加入JavaScript代碼關閉我的header.php,footer.php和模板文件的底部(的一個<script type="text/javascript"></script>標籤內我在那個特定的頁面上使用它,但它不工作。添加javascript代碼後,我在頁面內容區域添加<div class="event_list"></div>,因爲這是我想要的代碼工作,但它不工作。我包括jquery庫在head.php文件裏面的'head'標籤,我也嘗試了onLoad方法,通過將代碼添加到javascript的頂部,但是,可惜的是,它沒有工作,請幫助我。

P.S我的網站正在運行Wordpress。

+7

「它沒有工作」沒有幫助。控制檯中有錯誤嗎? – 2013-03-18 16:26:49

+0

您是否添加了外部資源? – jcubic 2013-03-18 16:31:22

回答

2

你把它包裝在document.ready中嗎?你的jQuery不會處理加載時不存在的元素。

$(document).ready(function() { 
    ... 
}); 

或簡寫

$(function() { 
    ... 
}); 
+0

+1。由於JSFiddle默認提供了文檔就緒包裝器,因此在轉移到您的應用程序時很容易錯過。 – 2013-03-18 16:30:10

+0

我試過你的建議,但它仍然無法正常工作。它在控制檯內部產生這個錯誤: 'Uncaught TypeError:對象[object Object]的屬性'$'不是函數' 引用'$(document).ready(function(){' – 2013-03-18 20:55:37

+0

聽起來像jQuery沒有加載,或者可能在你的函數之後才加載 – isherwood 2013-03-18 20:59:46

2

的小提琴被設置爲代碼在DOM就緒運行。所以你需要在onready調用中將代碼包裝在JavaScript部分中。

<script> 
$(function() { 

    /* 
     Eventbrite Examples - organizer event list 

     If you copy this code, please set your own API Key in the example below. 
     You can request one here: http://www.eventbrite.com/api/key 
    */ 

    Eventbrite({'app_key': "HSMTSI2CUDKAXFTXX2"}, function(eb){ 

     // define a few parameters to pass to the API 
     // Options are listed here: http://developer.eventbrite.com/doc/organizers/organizer_list_events/ 
     var options = { 
      'id' : "1667880002" 
     }; 

     // provide a callback to display the response data: 
     eb.organizer_list_events(options, function(response){ 
      $('.event_list').html(eb.utils.eventList(response, eb.utils.eventListRow)); 
     }); 
    } 

);  
}); 
</script> 
+0

你可以也會將

  • 11. 將Facebook從一個網站轉移到另一個網站
  • 12. 如何將biblio節點從舊網站轉移到新網站?
  • 13. 如何將兩個wordpress網站轉移到新的網站
  • 14. 無法創建網站錯誤(新)
  • 15. 無法在網站上創建標題?
  • 16. 將Sharpoint網站遷移到Google網站
  • 17. 將php/js網站轉換爲手機...創建新網站?
  • 18. 建立網站的託管,然後將其轉移到vps
  • 19. 如何將常規創建的網站/應用從MAMP轉移到流星
  • 20. WordPress主題無法轉移到活網站
  • 21. 子網站所有者無法創建子網站,SharePoint 2013
  • 22. 無法使用網站模板創建網站 - SharePoint 2013
  • 23. 將html遷移到網站
  • 24. 將網站遷移到WIKI
  • 25. 將網站遷移到wordpress
  • 26. 網站上的CNAME網址轉移到
  • 27. 將ASP.Net網站轉移到64位機器 - 獲取「無法顯示此頁面」
  • 28. 出口的jsfiddle上傳到網站
  • 29. 將Wordpress網站遷移到本地WAMPserver,現在無法找到網頁
  • 30. Visual Studio無法檢測到新創建的類爲asp.net「網站」