I am currently working on a Typescript project that utilizes JQuery, specifically for uploading a form with a file using the JQuery Form Plugin. However, after the upload process, there seems to be an issue when trying to call the "done" function from JQueryDeferred, resulting in an error being thrown by the browser.
To ensure proper typing, I have integrated the Typescript definition from Definitely Typed for JQuery into my project.
Below is the snippet of code where I am experiencing the problem:
this.JQuerySelector().ajaxSubmit().done(function (data) {
var x = data;
alert("Success : " + x);
}).fail(function (data) {
var x = data;
alert("Error : " + x);
});
The ajaxSubmit function belongs to the "JQuery Form plugin," and here is its TypeScript definition:
interface JQuery
{
ajaxSubmit(arg:{error:any; success:any}): JQuery;
ajaxSubmit(): JQueryDeferred<JQuery>;
ajaxForm(): JQuery;
}
Although I have created a partial definition myself, I am uncertain if it is accurate. The console in the browser displays the following error message:
Uncaught TypeError: Object [object Object] has no method 'done' DivAndSpan.ts:243 FileUploader.startUpload DivAndSpan.ts:243 (anonymous function) Start.ts:50 x.event.dispatch jquery.js:5095 v.handle jquery.js:4766
While the file successfully uploads, I do not receive the POST response and the "done" function remains uncalled.