Javascript 无法将JSFIDLE创建传输到网站
我正在尝试将JSFIDLE创建转移到我的网站,但我无法这样做。以下是它的链接: 我已经尝试将Javascript 无法将JSFIDLE创建传输到网站,javascript,jquery,wordpress,jsfiddle,Javascript,Jquery,Wordpress,Jsfiddle,我正在尝试将JSFIDLE创建转移到我的网站,但我无法这样做。以下是它的链接: 我已经尝试将标记中关闭的javascript代码添加到我的header.php、footer.php和模板文件的底部(我在特定页面上使用的一个,但它不起作用。添加javascript代码后,我在页面内容区域中添加,因为我希望代码在那里工作,但它不起作用。我在header.php文件中的'head'标记中包含jquery库。我还通过添加代码t尝试了onLoad方法o javascript的顶部,但遗憾的是,它不起作用
标记中关闭的javascript代码添加到我的header.php、footer.php和模板文件的底部(我在特定页面上使用的一个,但它不起作用。添加javascript代码后,我在页面内容区域中添加
,因为我希望代码在那里工作,但它不起作用。我在header.php文件中的'head'标记中包含jquery库。我还通过添加代码t尝试了onLoad方法o javascript的顶部,但遗憾的是,它不起作用。请帮助我
p.S我的网站正在运行Wordpress。您是否将其包装在document.ready中?您的jQuery在加载时不会对不存在的元素执行操作
$(document).ready(function() {
...
});
还是速记
$(function() {
...
});
fiddle被设置为让代码在DOM Ready上运行,因此您需要在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>
$(函数(){
/*
Eventbrite示例-组织者事件列表
如果复制此代码,请在下面的示例中设置自己的API密钥。
您可以在此处申请:http://www.eventbrite.com/api/key
*/
Eventbrite({'app_key':“HSMTSI2CUDKAXFTXX2”},函数(eb){
//定义几个要传递给API的参数
//选项如下所示:http://developer.eventbrite.com/doc/organizers/organizer_list_events/
变量选项={
“id”:“1667880002”
};
//提供回调以显示响应数据:
eb.组织者列表事件(选项、功能(响应){
$('.event_list').html(eb.utils.eventList(response,eb.utils.eventListRow));
});
}
);
});
“它不起作用”没有帮助。你在控制台中有错误吗?你添加了外部资源吗?+1。由于JSFIDLE默认情况下将提供doc ready包装,因此在传输到你的应用程序时很容易错过。我尝试了你的建议,但仍然不起作用。它在控制台中生成此错误:“Uncaught TypeError:objec的属性“$”t[object object]不是引用“$(document).ready(function()的函数”{'听起来jQuery好像没有加载,或者可能是在函数完成后才加载。好吧,我把你上面给出的代码放在我的页面底部,从google的CDN加载jQuery,它现在在控制台中返回这个错误:“uncaughtreferenceerror:Eventbrite未定义”指的是“Eventbrite({'app_key'):“HSMTSI2CUDKAXFTXX2”},函数(eb){不知道。我不知道Eventbrite是什么。您也可以将块放在page@DavidFregoli,只是复制JSFIDLE正在执行的操作。我也尝试了您的建议,但仍然不起作用。它在控制台中生成此错误:“UncaughtTypeError:object[object]的属性“$”不是引用“$(function(){”的函数。您是否正确链接到jQuery?
<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>