admin管理员组

文章数量:1327750

I have the following code:

    $.ajax({
        url: modal.href,
        dataType: 'json',
        type: 'POST',
        data: modal.$form.serializeArray()
    })
        .done(onSubmitDone)
        .fail(onSubmitFail);

TypeScript points to the $.ajax and gives a message saying:

Supplied parameters do not match any signature of call target.

However from what I can see my $.ajax is correct and I am correctly referencing the jQuery definitions. Can anyone suggest what might be wrong?

I have the following code:

    $.ajax({
        url: modal.href,
        dataType: 'json',
        type: 'POST',
        data: modal.$form.serializeArray()
    })
        .done(onSubmitDone)
        .fail(onSubmitFail);

TypeScript points to the $.ajax and gives a message saying:

Supplied parameters do not match any signature of call target.

However from what I can see my $.ajax is correct and I am correctly referencing the jQuery definitions. Can anyone suggest what might be wrong?

Share Improve this question edited Oct 29, 2012 at 8:44 Fenton 251k73 gold badges401 silver badges409 bronze badges asked Oct 29, 2012 at 8:06 user1679941user1679941
Add a ment  | 

2 Answers 2

Reset to default 4

Referring to jquery.d.ts:

ajax(url: string, settings: JQueryAjaxSettings);

This is the signature of ajax function. You should move the url out of the settings object and pass in as a parameter instead for typescript to accept. Or edit the jquery.d.ts definitions to accept settings only function call.

While the initial jQuery definitions do not contain the overload without the Url, they have been updated and you can take the latest version from CodePlex: http://typescript.codeplex./SourceControl/BrowseLatest

There is also a mirror of the latest updated jQuery definitions at https://github./borisyankov/DefinitelyTyped

本文标签: javascriptajax call not recognized by TypeScriptStack Overflow