开发者

Object required?

开发者 https://www.devze.com 2023-02-11 03:38 出处:网络
$(document).ready(function(){ function openEditor(){ $(\"#editor\").show().animate({width: 965, height: 380}, 1500);
$(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').va开发者_如何转开发l() , 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

});

Hello,

At row 138 and row 157 i get some strange error that an object (?) is required? I've been working on it all day and it still isn't working...

Help! Please!

Greetings!


You can only use jQuery's event.timeStamp from functions that pass through an event argument, i.e. click. So you'll need to get the timeStamp yourself in this case. So change line 157 from:

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

to (if you want a timestamp, i.e. number of ms since 1/1/1970):

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

Or (if you want the actual date/time):

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

Working fiddle example here.


You are wrapping all of your code withing the ready() context. You only need to wrap your start-up code in there.

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

.. your code ..


Looking @ 157,

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

will fail if there is no element with id="ready" on load.

0

精彩评论

暂无评论...
验证码 换一张
取 消