2

以下のjQueryコードがありますが、when().done()期待どおりに機能しません。これupdateResultFooter()はベドーレと呼ばれ、doReverseSearch()その方法で彼女の仕事を終えます。replaceその結果、私のビューのボタンが有効になり、メソッドのの後にデフォルト値(無効)を取り直しますdoReverseSearch()

$("#idBnSearch").click(function () 
{
    $.when(doReverseSearch(telValue, pageIndex, methodUrl))
    .done(function () 
    {
        updateResultFooter("@ViewBag.CountResult", pageIndex, "@ViewBag.PageCount");
    });

});

function updateResultFooter(resultCount, pageIndex, pageCount) 
{
    if (pageIndex == 0)
        $("#bnPreviousPage").attr('disabled', 'disabled');
    else
        $("#bnPreviousPage").removeAttr('disabled');

    if ((pageIndex + 1) == pageCount)
        $("#bnNextPage").attr('disabled', 'disabled');
    else
        $("#bnNextPage").removeAttr('disabled');
    }

function doReverseSearch(telValue, pageIdx, methodUrl) 
{
    $.ajax(
    {
        url: methodUrl,
        type: 'post',
        data: JSON.stringify({ Telephone: telValue, pageIndex: pageIdx }),
        datatype: 'json',
        contentType: 'application/json; charset=utf-8',
        success: function (data) {
            $('#result').replaceWith(data);
        },
        error: function (request, status, err) {
            alert(status);
            alert(err);
        }
    });
}

前もって感謝します

4

0 に答える 0