I'm trying to convert this JQuery plugin to typescript:
http://malsup.com/jquery/form/#download
But I'm not able to get Intellisense to recognize the function in typescript. I just need one function from the this plugin - "ajaxSubmit". I've declared it i a .d.ts file in my typescript project and added a reference to it from the main file. However, Webstorm does not seem to know that function and throws an error. Here's the .d.ts
interface JQuery
{
ajaxSubmit(error:any, success:any): JQuery;
}
I've taken a look at this page and tried to follow the intruction in there.
Using jQuery plugin in TypeScript
Here's the program that implements AjaxSubmit. Webstorm throws an error that says: $(this) : Argument does not match parameters.
var $form = $("#fileUploadForm");
$form.submit(function (e) {
// perform client side validations if any
$(this).ajaxSubmit({
error: function () {
// handle error
},
success: function (response) {
// handle success
}
});
// Important: stop event propagation
return false;
});
By the way, I'm using NodeJS + ExpressJs in the back end, I dont think it concerns this question.