Javascript jqueryajax称为';单击';对未实现接口HtmleElement的对象调用

Javascript jqueryajax称为';单击';对未实现接口HtmleElement的对象调用,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有以下javascript: $('#edit_category').on('click','#btn_save_category_name',function(){ currently_edit.text($('#txt_edit_category').val()); edit_category_name(currently_edit,current_category_id); $('#edit_category').modal('hide') }) functi

我有以下javascript:

$('#edit_category').on('click','#btn_save_category_name',function(){
    currently_edit.text($('#txt_edit_category').val());

    edit_category_name(currently_edit,current_category_id);
    $('#edit_category').modal('hide')
})

function edit_category_name(name, id){
    $.ajax({
        type: 'POST',
        url: '/Category/edit_team_category',
        dataType: 'json',
        data: {
            request: 'ajax',
            name: name,
            id: id
        },
        success: function (data) {

        }
    });
}
现在,当我尝试这样做时,我得到了以下错误:
调用了'click',调用了一个不实现接口Htmlement的对象。

但是如果我注释掉函数行aka:
edit\u category\u name(当前\u edit,当前\u category\u id)

一切正常

谁能告诉我为什么会这样

更新我的完整脚本

var mode = 'team';
var currently_edit = '';
var current_team_id = 0;
var current_category_id = 0;

jQuery(document).ready(function(){

    //Main click function for Team (selection of team)
    $('#team_wrapper').on('click', '.panel-heading', function () {
        if(mode === 'team'){
            current_team_id = $(this).siblings('small').text()
            title = $(this).find('.text-white').text();
            var i = 100;
            $('#span_search').hide();
            $('#btn_new_team').fadeOut();
            $('.col-lg-3').each(function(){
                $('.alt').toggle('slow');
                $(this).fadeOut(300,function(){
                    $(this).remove();
                });
            });
            $('#team_title').text('Select Category');
            $('#btn_new_category').delay(500).fadeIn();
            $('#selected_team_name').text(title);
            $('#selected').delay(695).fadeIn();
            $('#span_search').delay(500).fadeIn();
            $('#back').delay(500).fadeIn();
            generate_categories();

            mode = 'category';
        }else{
            $(this).next('div').find('a')[0].click();
        }
    })

    $('#team_wrapper').on('click', '.btn_administrate', function(){
        current_team_id = $(this).next('.team_id').text();
        load_team_members(current_team_id);
    });


    //Modal category:

    //create
    $('#btn_create_category').click(function(){
        add_category($('#txt_create_category').val());
        $('#group-form').modal('hide');
        $('#txt_create_category').val('');
    })

    // edit
    $('#team_wrapper').on('click','.team_category_edit',function(){
        current_category_id= $(this).next('input').val()
        edit_mode('txt_edit_category',$(this).closest("div").prev().find("h3"));
    })

    $('#edit_category').on('click','#btn_save_category_name',function(){
        currently_edit.text($('#txt_edit_category').val());

        edit_category_name(currently_edit,current_category_id);
        $('#edit_category').modal('hide')
    })

});


function edit_category_name(name, id){
    $.ajax({
        type: 'POST',
        url: '/Category/edit_team_category',
        dataType: 'json',
        data: {
            request: 'ajax',
            name: name,
            id: id
        },
        success: function (data) {
        }
    });
}
在本例中:

    var current_team_id = 1;
var current_category_id = 2;

当前编辑的值是多少?我假设这是一个jQuery对象,而不是一个文本值。请尝试以下方法

edit_category_name(currently_edit.text(),current_category_id);
更新

正如Barmar提到的,根据您共享的内容,当前的_edit.text(…)是无效的。也许你想做的是:

currently_edit = $('#txt_edit_category').val();

尝试更改此行
当前的\u edit.text($('#txt\u edit\u category').val()


使用此选项:
Current_edit=$('#txt_edit_category').val()

我很想帮忙,但您的代码片段看起来不完整。当前编辑的
和当前类别id
变量来自哪里?根据您使用它们的方式,它们看起来像是jQuery对象,但您将其包含在
数据
键中
$.ajax()
,就像它是一个字符串一样?我在这里没有看到任何会导致调用“click”函数的内容。当前的两个\u category\u id和当前的\u edit是两个“全局的”变量我可以添加我所有的代码,但它是一个相当大的脚本,您正在将
当前的
传递到
编辑类别的
名称的
参数,然后它在AJAX调用中使用该参数作为
名称:
参数。但是
current\u edit
是一个jQuery对象,而不是任何东西的名称。
current\u edit.text(…)
毫无意义
Current_edit
是一个空字符串,不是jQuery对象。你从来没有重新分配过它。@Micheal我已经添加了我的一些脚本(相关的脚本)