So basically, I have a small plugin like below, what it does is submit the form with jquery method post.
(function($){
$.fn.ajaxSubmit = function(options){
var defaults = {
url:'',
success:function(){},
error:function(){}
},
o = $.extend({},defaults, options);
return this.each(function(){
var $this=$(this);
$this.submit(function(e){
$.post(o.url,$this.serialize() ,
function(response){
if(response.status == 'success'){
o.success.call(this);
}
else if(response.status == 'error'){
o.error.call(this);
}
},'json');
return false;
});
});
}
})(jQuery);
This is how its called
$('#form').ajaxSubmit({
url:'www.myownwebsite.com/play/processform',
success:function(response){alert(response.status)},
error:function(response){alert(response.status);}
});
The problem is, when the script is executed开发者_C百科, I get the error "response is undefined". Clearly I know whats wrong, but how can I do it properly?
have you tried o.success.call(this,response);
精彩评论