I created two methods on a Javascript class:
this.saveData = function(){
var url_send = 'm1=1&m2=2'
$.ajax({
url: '/save.php',
dataType : "text",
data:url_send,
type:'POST',
success: function(data) {
// this is does not correct
this.showAcceptBox('error_msg_0');
}
});
};
this.showAcceptBox = function(msg_id){
$('#error_box').removeClass('alert-negative');
$('#error_box').html($('#'+msg_id).html());
$('#error_box').show();
setTimeout(function(){
$('#error_box').fadeOut('slow',function(){
$('#error_box').addClass('alert-negative');
});
},this.message_box_timeout);
};
How do I correct the call method from my class into jQuery .ajax()?
Try to capture
thisin a closure:or pass it as parameter using the
contextswitch:Quote from the documentation: