SyntaxError:function语句需要名称jQuery UI

SyntaxError:function语句需要名称jQuery UI,jquery,jquery-ui,jquery-ui-sortable,Jquery,Jquery Ui,Jquery Ui Sortable,我正试图用以下代码创建一个可排序列表: $("#responds").sortable(function() { axis: 'y'; update: function(event, ui) { var data = $(this).sortable('serialize'); $.ajax({ type: 'POST', url: 'process.php', da

我正试图用以下代码创建一个可排序列表:

$("#responds").sortable(function() {
    axis: 'y';
    update: function(event, ui) 
    {
        var data = $(this).sortable('serialize');
        $.ajax({
            type: 'POST',
            url: 'process.php',
            data: {position: data},
            dataType: "html",
            success: function(data) { alert("hej"); },
            error: function(xhr, ajaxOptions, thrownError) { alert(thrownError); }
        });
    }
});
但这只会产生以下信息:

SyntaxError: function statement requires a name


update: function(event, ui)

我不明白为什么…

你用分号来结束它。你要逗号吗

$("#responds").sortable({
    axis: 'y',
    update: function(event, ui) {
        var data = $(this).sortable('serialize');
        $.ajax({
            type     : 'POST',
            url      : 'process.php',
            data     : {position: data},
            dataType : "html",
            success  : function(data) { 
                alert("hej"); 
            },
            error    : function(xhr, ajaxOptions, thrownError) { 
                alert(thrownError); 
            }
        });
    }
});

你用分号来结束它。你要逗号吗

$("#responds").sortable({
    axis: 'y',
    update: function(event, ui) {
        var data = $(this).sortable('serialize');
        $.ajax({
            type     : 'POST',
            url      : 'process.php',
            data     : {position: data},
            dataType : "html",
            success  : function(data) { 
                alert("hej"); 
            },
            error    : function(xhr, ajaxOptions, thrownError) { 
                alert(thrownError); 
            }
        });
    }
});

你用分号来结束它。你要逗号吗

$("#responds").sortable({
    axis: 'y',
    update: function(event, ui) {
        var data = $(this).sortable('serialize');
        $.ajax({
            type     : 'POST',
            url      : 'process.php',
            data     : {position: data},
            dataType : "html",
            success  : function(data) { 
                alert("hej"); 
            },
            error    : function(xhr, ajaxOptions, thrownError) { 
                alert(thrownError); 
            }
        });
    }
});

你用分号来结束它。你要逗号吗

$("#responds").sortable({
    axis: 'y',
    update: function(event, ui) {
        var data = $(this).sortable('serialize');
        $.ajax({
            type     : 'POST',
            url      : 'process.php',
            data     : {position: data},
            dataType : "html",
            success  : function(data) { 
                alert("hej"); 
            },
            error    : function(xhr, ajaxOptions, thrownError) { 
                alert(thrownError); 
            }
        });
    }
});


我已经试过了。我得到这个:SyntaxerError:missing;在语句更新之前:function(event,ui)@user500468-这将是函数调用,请参阅我更新的答案。谢谢,但是我的代码和你的代码有什么区别?我找不到它有什么不同。它没有一个应该有对象的函数!非常感谢!:)我已经试过了。我得到这个:SyntaxerError:missing;在语句更新之前:function(event,ui)@user500468-这将是函数调用,请参阅我更新的答案。谢谢,但是我的代码和你的代码有什么区别?我找不到它有什么不同。它没有一个应该有对象的函数!非常感谢!:)我已经试过了。我得到这个:SyntaxerError:missing;在语句更新之前:function(event,ui)@user500468-这将是函数调用,请参阅我更新的答案。谢谢,但是我的代码和你的代码有什么区别?我找不到它有什么不同。它没有一个应该有对象的函数!非常感谢!:)我已经试过了。我得到这个:SyntaxerError:missing;在语句更新之前:function(event,ui)@user500468-这将是函数调用,请参阅我更新的答案。谢谢,但是我的代码和你的代码有什么区别?我找不到它有什么不同。它没有一个应该有对象的函数!非常感谢!:)