Thank you in advance.
I need to build a JS file that contains some useful functions and wich will be reused on my website.
Content of File 1: utils.js
function clearForm(form){
$(form).find('input:text, input:password, input:file, select, textarea').val('');
$(form).find('input:radio, input:checkbox')
.removeAttr('checked').removeAttr('selected');
}
function anotherFunction(){
//
}
function anotherFunction1(){
//
}
and this is the file 2: control.js
function postRecovery(email) {
var retorno;
$.ajax({
url: "/auth/doRecuperarSenha/",
dataType: "json",
contentType: "application/json;charset=utf-8",
type: "POST",
data: JSON.stringify(email),
async: true,
beforeSend: function () {
NProgress.start();
},
success: function (dados) {
retorno = dados;
},
error: function () {
alert("Erro");
},
complete: function () {
**this.clearForm(*email*);**
NProgress.done();
}
});
NProgress.remove();
}
But this does not work.
Clarification
I've imported the utils.js file before the control.js file on my html structure
My code worked when i put the script on the same file.