2011-02-15 70 views
-1
$(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

什麼`event`(你的157行)?沒有引用其他地方... – acm 2011-02-15 16:37:23

+0

$('#ready')實際上是否找到任何東西?事件是否定義在這一點上? – 2011-02-15 16:37:37

+1

你在用什麼調試器? – Pointy 2011-02-15 16:43:08

回答

1

您只能使用jQuery的event.timeStamp函數通過事件參數,即click。所以在這種情況下你需要自己獲得timeStamp。因此,改變線從157:

$("#ready").html('Document ready at '+ event.timeStamp); // Row 157 

到(如果你想有一個時間戳,因爲1/1/1970即數毫秒):

$("#ready").html('Document ready at '+ new Date().getTime()); 

或者(如果你想實際的日期/時間):

$("#ready").html('Document ready at '+ new Date.now()); 

Working fiddle example here.

0

您正在使用ready()上下文打包所有代碼。你只需要把你的啓動代碼包裝在那裏。如果沒有與ID負載= 「準備好了」 無元素

$(document).ready(function() { 
    init() //or whatever 
} 

..你的代碼..

-1

展望@ 157,

$("#ready").html('Document ready at '+ event.timeStamp); // Row 157 

將失敗。