3

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?

4

2 回答 2

4

参考 jquery.d.ts:

ajax(url: string, settings: JQueryAjaxSettings);

这是ajax函数的签名。您应该将 url 从设置对象中移出并作为参数传入,而不是让 typescript 接受。或编辑 jquery.d.ts 定义以接受仅设置函数调用。

于 2012-10-29T08:11:58.863 回答
3

虽然最初的 jQuery 定义不包含没有 Url 的重载,但它们已经更新,您可以从 CodePlex 获取最新版本:http: //typescript.codeplex.com/SourceControl/BrowseLatest

https://github.com/borisyankov/DefinitelyTyped上还有最新更新的 jQuery 定义的镜像

于 2012-10-29T23:17:21.383 回答