I am trying to create a jquery plugin. This is a validation plugin. After submitting the form, I want to submit data using ajax. I am creating a validate constructor and inheriting it as a prototype. But I cannot use the default value outside the jquery namespace.
I want to use the ops variable as a global variable, since I can access it from a javascript prototype. So, I need an effective way to do this.
(function($){
$.fn.validation = function(options){
var ops = $.extend({}, $.fn.validation.defaults, options);
};
}(jQuery));
$.fn.validation.defaults = {
url: 'validation.php',
methodType: 'post',
};
function Validate(){
this.error = [];
}
Validate.prototype = {
constructor : Validate,
submitForm : function(currentForm){
var formData = new FormData(currentForm);
$.ajax({
url: opt.url,
type: opt.methodType,
success: function(data){
},
data: formData,
cache: false,
contentType: false,
processData: false
});
}
};
source
share