jquery ajax提交回调获取此壁橱

jquery ajax提交回调获取此壁橱,jquery,Jquery,Therr是页面中的一个按钮,当页面提交时, 我将得到form元素中的值, 但是我得不到, 请给出一些要点,谢谢。将相关上下文设置为完成回调,例如使用bind和btw,更喜欢使用最近的: 我一点也不清楚你想描述什么。代码中的注释表示存在错误。错误是什么?这段代码试图做什么,在什么时候失败了?发生这种情况时,运行时的值是什么?此内部完成回调指的不是您所想的…非常感谢,我将在将来关注您。 $(document).on('click', '#file-submit', function () {

Therr是页面中的一个按钮,当页面提交时, 我将得到form元素中的值, 但是我得不到, 请给出一些要点,谢谢。

将相关上下文设置为完成回调,例如使用bind和btw,更喜欢使用最近的:


我一点也不清楚你想描述什么。代码中的注释表示存在错误。错误是什么?这段代码试图做什么,在什么时候失败了?发生这种情况时,运行时的值是什么?此内部完成回调指的不是您所想的…非常感谢,我将在将来关注您。
$(document).on('click', '#file-submit', function () {

    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        data: formData,
        processData: false,
        contentType: false
    }).done(function (data, status, jqxhr) {
        //here will be get a error
        var nextId = $(this).parents('.tab-pane').next().attr("id");
        alert(nextId);

    }).fail(function (data, status, jqxhr) {
        console.log("error");
    });
})
$(document).on('click', '#file-submit', function () {

    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        data: formData,
        processData: false,
        contentType: false
    }).done(function (data, status, jqxhr) {
        //now 'this' refers to clicked element
        var nextId = $(this).closest('.tab-pane').next().attr("id");
        alert(nextId);

    }.bind(this)).fail(function (data, status, jqxhr) {
        console.log("error");
    });
})