Я изучаю jQuery самостоятельно и нуждаюсь в небольшой помощи здесь, пожалуйста.jQuery - простая глобальная переменная
Я не знаю, почему, но переменная «msg» в этом коде ниже подходит к концу в конце.
jQuery(function($) {
$('#mailing').submit(function(e) {
e.preventDefault();
var msg = '';
$.ajax({
type: "POST",
url: "ajx_mailing.asp",
data: '[email protected]',
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();
});
}
});
});
});
Модальное сообщение не заполнено? Ты знаешь почему?
Спасибо!
возможно дубликат [Как вернуть ответ от вызова AJAX?] (Http://stackoverflow.com/questions/14220321/how-to-return- a-response-from-a-ajax-call) –