Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对象不支持此属性或方法–Javascript错误_Javascript_Ajax - Fatal编程技术网

对象不支持此属性或方法–Javascript错误

对象不支持此属性或方法–Javascript错误,javascript,ajax,Javascript,Ajax,大家好,我有一个很好的javascript项目要做。我开始尝试切换一些javascript,但我在这里遇到了一个错误: function saveComment( id ) { $("#commentErrors").css("visibility", "hidden"); var hashTab = {}; commentField = document.getElementById("comments-"+id); // hard code the

大家好,我有一个很好的javascript项目要做。我开始尝试切换一些javascript,但我在这里遇到了一个错误:

    function saveComment( id )
{
    $("#commentErrors").css("visibility", "hidden");

    var hashTab = {};
    commentField = document.getElementById("comments-"+id);

    // hard code the constant Node.TEXT_FIELD as its value "3" since
    // IE doesn't support DOM constants correctly
    hashTab["comments"] = commentField.firstChild.nodeType==3
                        ? commentField.innerHTML
                        : commentField.firstChild.value;



    hashTab["id"] = id;
    //hashTab["entryWorkloadYear"] = document.getElementById("entryWorkloadYear").value;  // Where is this element?!

  ----->>>      WhatIfDataAction.saveComment(hashTab,
            {
                callback:saveCommentCallback,
                timeout:60000,
                errorHandler: dwrSessionErrorHandler
            }
        );
}
有什么想法吗

saveComment如下所示:

    public CommentForm saveComment(Map<String,String> properties)
throws Exception
{
EntryBean entry = WhatifCache.fetchEntryFromCache(getSession());
CommentForm form = new CommentForm(properties);
if (form.validate(this))
{
    CommentBean bean = entry.getComment(form.getId());

    bean = CommentBean.deepCopy(bean);

    form.overlayFormData(bean);

    entry.updateComment(bean);
}

return form;

}

该错误意味着WhatIfDataAction对象没有名为saveComment的方法。

Unlrelated,但var hashTab={};是一个对象,您需要一个数组:var hashTab=[];saveComment显然不是WhatIfDataAction的属性。我们看不到在哪里定义了WhatIfDataAction,也看不到在哪里填充了它的属性,因此我们不能告诉您任何比错误消息更有用的信息。@Diodeus真的吗?如果hashTab是一个数组,他怎么能做hashTab[id]=id;?thanx的反馈家伙…我现在检查它savecomment不是javascript!看起来像是c或java。。。