$(document).ready(function(){
function openEditor(){
$("#editor").show().animate({width: 965, height: 380}, 1500);
$("#editor textarea").show();
}
function closeEditor(){
$("#editor").animate({width: 985, height: 1}, 1500, function(){
$("#editor").hide();
$("#editor textarea").hide();
});
}
function setedit(){
$.ajax({
type: "POST",
url: "engine.php",
data: "title="+ $('#editorTitle').attr('value') +"&text="+ $('#editorText').html(),
beforeSend: function(){
$('#mainField').html('<img src="data/images/loader.gif" alt="Loading...">');
},
success: function(msg){
alert(msg);
closeEditor();
search();
}
});
}
function search(){ // Row 138
$('#editorTitle').val($('#search').val());
$('#mainField').html('<img src="data/images/loader.gif" alt="Loading...">');
$.get('engine.php?search='+ $('#search').val() , function(data) {
$('#mainField').html(data);
});
$.get('engine.php?raw=true&search='+ $('#search').val() , function(data2) {
$('#editorText').html(data2);
});
$.get('engine.php?title=true&search='+ $('#search').val() , function(data2) {
$('#h1').html(data2); // Row 152
$('#editorTitle').html(data2);
});
}
$("#ready").html('Document ready at '+ event.timeStamp); // Row 157
});
您好,
在第138行和第157行,我得到一个奇怪的错误,需要一个对象(?)? 我一整天都在努力,但仍然无法正常工作......
帮助!请!
问候!
答案 0 :(得分:1)
您只能使用来自通过事件参数的函数的jQuery event.timeStamp
,即click
。因此,在这种情况下,您需要自己获取timeStamp。因此,改变第157行:
$("#ready").html('Document ready at '+ event.timeStamp); // Row 157
to(如果你想要一个时间戳,即自1970年1月1日以来的毫秒数):
$("#ready").html('Document ready at '+ new Date().getTime());
或(如果您想要实际日期/时间):
$("#ready").html('Document ready at '+ new Date.now());
答案 1 :(得分:0)
您将所有代码包装在ready()上下文中。您只需将启动代码包装在那里。
$(document).ready(function() {
init() //or whatever
}
..你的代码..
答案 2 :(得分:-1)
看@ 157,
$("#ready").html('Document ready at '+ event.timeStamp); // Row 157
如果加载时没有id =“ready”的元素,将失败。