$("document").ready(function(){
contM = $('#main-content');
contS = $('#second-content');
$(contM).hide();
$(contS).hide();
function loadURL(url) {
console.log("loadURL: " + url);
$.post(url,{post_loader: 1},{post_loader: 1}, function(data){
$(contM).html($(data));
$(contM).show();
});
}
// Event handlers
$.address.init(function(event) {
console.log("init: " + $('[rel=address:' + event.value + ']').attr('href'));
}).change(function(event) {
$.post($('[rel=address:' + event.value + ']').attr('href'), {post_loader: 1}, function(data){
$(contM).html($(data));
$(contM).show();
});
console.log("change");
})
$('.update-main a').click(function(){
loadURL($(this).attr('href'));
});
});
我正在使用此代码调用服务器来更新网页的主要内容。 Google Chrome中的一切正常,但无法在Firefox中正常执行。
奇怪的是,当我打开控制台监视服务器通信时,应用程序工作正常,只有当它关闭时才会出现问题:脚本开始与服务器通信,但在接收数据之前,浏览器跳转到源URL。
我在firebug控制台中不断收到此错误:e.success.call不是函数 Webdev的/ lostine /可湿性粉剂内容/主题/ lostine / JS / jQuery的1.4.1.min.js 第121行
任何想法?
答案 0 :(得分:0)
在wesgarrison评论时,console
并不总是出现在FireFox中,就像在Chrome中一样,您会收到console is undefined
错误。在不调试时,您需要注释掉console.log()
行,或将它们包装在if(console){}
支票中。
控制台出局时它起作用的原因... console
已经定义,没有错误:)
答案 1 :(得分:0)
要使用和不使用控制台来处理不同的浏览器,我使用Paul Irish的包装器http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog的略微改编的版本:
window.log = function ()
{
if (window.console) {
if (console.firebug) {
console.log.apply(console, Array.prototype.slice.call(arguments));
} else {
console.log.call(console, Array.prototype.slice.call(arguments));
}
}
};