I am learning jQuery by myself, and need a little help here, please.
I do not know why, but the "msg" variable in this code bellow is coming up empty in the end.
jQuery(function($) {
$('#mailing').submit(function(e) {
e.preventDefault();
var msg = '';
$.ajax({
type: "POST",
url: "ajx_mailing.asp",
data: 'email=test@test.com',
cache: false,
dataType: "text",
complete: function(data){
if (data.responseText = 'ok') {
msg = 'The e-mail was included with success!';
} else {
msg = 'There is a problem, please check the e-mail!';
}
},
error: function(data) {
msg = 'Error! Please, try again latter!';
},
});
/* http://www.ericmmartin.com/projects/simplemodal/ */
$('#simplemodal').modal({
minWidth: 410,
minHeight: 120,
position: ['30%',],
overlayId: 'msgbox-overlay',
containerId: 'msgbox-container',
onShow: function(dialog) {
var modal = this;
$('.header', dialog.data[0]).append('Mailing List');
$('.message', dialog.data[0]).append(msg);
$('.ok', dialog.data[0]).click(function() {
modal.close();
});
}
});
});
});
The modal message is blank? Do you know why?
Thanks!