Здравствуйте,
использую готовый модуль на сайте (ng_wall): форма - отправка сообщения,
форма отправляет данные ajax -ом
хочу доработать этот модуль и дописать отправку результата формы на почту.
при сипользовании drpal_mail ajax Выдает ошибку AJAX HTTP ошибка 200.
как мне исправить ошибку?
спасибо за любую помощь.
код инициализации формы
<?php$form['uid'] = array(
'#type' => 'value',
'#value' =>$account->uid,
);
$form['return_new']=array(
'#markup'=>'<div id="ng-wall-message" class="clearfix"></div>',
);
$form['message']=array(
'#type'=>'textarea',
'#default_value'=>"",
'#cols'=>60,
'#rows'=>5,
'#prefix' =>'<div id="ng-wall-reload-wrapper">',
'#suffix' => '</div>',
);
$form['submit']=array(
'#type'=>'submit',
'#value'=>t('Send'),
'#ajax' => array('callback' => 'ng_wall_posted_form_ajax_submit'),
);
return $form;
}
}?>
код обработки сабмита
<?phpfunction ng_wall_posted_form_ajax_submit(&$form, &$form_state){
//вот здесь http://xandeadx.ru/blog/drupal/85 нашла, что можно и без хуков сделать отправку, вставила этот код
drupal_mail('system', 'mail', 'test@test.ru', 'ru', array(
'context' => array(
'subject' => 'Some subject',
'message' => 'Some message',
)
));
global $user;
if($form_state['values']['message']=="" || $form_state['values']['message']==NULL){
$commands[] = ajax_command_html('#ng-wall-message', t("Error: empty message"));
$commands[] = ajax_command_invoke('#ng-wall-reload-wrapper textarea', 'addClass', array('messages error'));
$commands[] = ajax_command_invoke('#ng-wall-message', 'removeClass', array('status'));
$commands[] = ajax_command_invoke('#ng-wall-message', 'addClass', array('messages error'));
return array('#type' => 'ajax', '#commands' => $commands);
}
//Стандартная обработка формы
$objFile = new stdClass();
$objFile->uid = $form_state['values']['uid'];
$objFile->poster_id = $user->uid;
$objFile->mail = $user->mail;
$objFile->poster_type = 'user';
$objFile->message = $form_state['values']['message'];
$objFile->time = time();
$objFile->status = 1;
$return=ng_wall_savePost($objFile);
// обновляем содержимое блока
if($return) {
$objFile->wid=$return;
$msg_array=array($objFile);
//Обновим счетчик сообщений
//$kol_all=ng_wall_countMsg($form_state['values']['uid']);
//$kol_new=ng_wall_countMsg($form_state['values']['uid'],1);
//$status=t('New kol_new | All kol_all',array('kol_new'=>$kol_new,'kol_all'=>$kol_all));
$place=variable_get('ng_wall_post_form',0);
if($place==1) $commands[] = ajax_command_prepend('#ng-wall-poster', _ng_wall_print_posters($msg_array));
if($place==2) $commands[] = ajax_command_append('#ng-wall-poster', _ng_wall_print_posters($msg_array));
$commands[] = ajax_command_invoke('#ng-wall-reload-wrapper textarea', 'val',array(''));
$commands[] = ajax_command_html('#ng-wall-message', t("Message send"));
$commands[] = ajax_command_invoke('#ng-wall-message', 'addClass', array('messages status'));
$commands[] = ajax_command_invoke('#ng-wall-message', 'removeClass', array('error'));
$commands[] = ajax_command_invoke('#ng-wall-reload-wrapper textarea', 'removeClass', array('error'));
//$commands[] = ajax_command_html('#ng-wall-all .status-wall',$status);
drupal_mail('system', 'mail', 'arina@pelican-style.ru', 'ru', array(
'context' => array(
'subject' => 'Some subject',
'message' => 'Some message'.$objFile->poster_id ,
)
));
}
else {$commands[] = ajax_command_html('#ng-wall-message', t("Error: Message not sent"));
$commands[] = ajax_command_invoke('#ng-wall-message', 'removeClass', array('status'));
$commands[] = ajax_command_invoke('#ng-wall-message', 'addClass', array('error'));
}
return array('#type' => 'ajax', '#commands' => $commands);
}
?>
отправляются сообщения на сайте через smtp, письмо приходит на почту, но при нажатии кнопки вот такое сообщение:
это код с консоли, в ответе от запроса ajax
Как мне исправить это?
jquery.min.js (строка 4)
/system/ajax
200 OK
516ms
jquery.min.js (строка 4)
ЗаголовкиPostОтветCookies
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 mx.xxx.xxx Microsoft ESMTP MAIL Service ready at Thu, 16 Jan 2014 12:57:52 +0700
"
SMTP -> get_lines(): $data is "220 mx.xxx.xxx Microsoft ESMTP MAIL Service ready at Thu, 16 Jan 2014 12:57:52 +0700
"
SMTP -> FROM SERVER:220 mx.xxx.xxx Microsoft ESMTP MAIL Service ready at Thu, 16 Jan 2014 12:57:52 +0700
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-mx.xxx.xxx Hello [192.168.1.7]
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
"
SMTP -> get_lines(): $str is "250-SIZE 10485760
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
"
SMTP -> get_lines(): $str is "250-PIPELINING
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
"
SMTP -> get_lines(): $str is "250-DSN
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
"
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
"
SMTP -> get_lines(): $str is "250-X-ANONYMOUSTLS
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
"
SMTP -> get_lines(): $str is "250-AUTH LOGIN
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
"
SMTP -> get_lines(): $str is "250-X-EXPS GSSAPI NTLM
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
"
SMTP -> get_lines(): $str is "250-8BITMIME
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
"
SMTP -> get_lines(): $str is "250-BINARYMIME
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
"
SMTP -> get_lines(): $str is "250-CHUNKING
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
"
SMTP -> get_lines(): $str is "250-XEXCH50
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
"
SMTP -> get_lines(): $data was "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
"
SMTP -> get_lines(): $str is "250 XRDST
"
SMTP -> get_lines(): $data is "250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250 XRDST
"
SMTP -> FROM SERVER: 250-mx.xxx.xxx Hello [192.168.1.7]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-X-ANONYMOUSTLS
250-AUTH LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250 XRDST
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6
"
SMTP -> get_lines(): $data is "334 VXNlcm5hbWU6
"
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6
"
SMTP -> get_lines(): $data is "334 UGFzc3dvcmQ6
"
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "235 2.7.0 Authentication successful
"
SMTP -> get_lines(): $data is "235 2.7.0 Authentication successful
"
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.1.0 Sender OK
"
SMTP -> get_lines(): $data is "250 2.1.0 Sender OK
"
SMTP -> FROM SERVER:250 2.1.0 Sender OK
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.1.5 Recipient OK
"
SMTP -> get_lines(): $data is "250 2.1.5 Recipient OK
"
SMTP -> FROM SERVER:250 2.1.5 Recipient OK
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "354 Start mail input; end with .
"
SMTP -> get_lines(): $data is "354 Start mail input; end with .
"
SMTP -> FROM SERVER:354 Start mail input; end with .
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.6.0 Queued mail for delivery
"
SMTP -> get_lines(): $data is "250 2.6.0 Queued mail for delivery
"
SMTP -> FROM SERVER:250 2.6.0 Queued mail for delivery
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "221 2.0.0 Service closing transmission channel
"
SMTP -> get_lines(): $data is "221 2.0.0 Service closing transmission channel
"
SMTP -> FROM SERVER:221 2.0.0 Service closing transmission channel
[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"antonelli","theme_token":"Vff91lupqKdooPL7u5QoRvRgGAS0HX6n58-mI-x1n2I"},"collapsible_comments":{"level":"0","mode":"0","effect":"hide"},"overlay":{"paths":{"admin":"node\/*\/webform\nnode\/*\/webform\/*\nnode\/*\/webform-results\nnode\/*\/webform-results\/*\nnode\/*\/submission\/*\nnode\/*\/outline\nnode\/*\/outline\/remove\nnode\/*\/access\nfield-collection\/*\/*\/edit\nfield-collection\/*\/*\/delete\nfield-collection\/*\/add\/*\/*\nmedia\/*\/edit\nmedia\/*\/multiedit\nmedia\/*\/delete\nmedia\/browser\nmedia\/browser\/*\nmedia-gallery\/detail\/*\/*\/edit\nmedia-gallery\/detail\/*\/*\/remove\nnode\/*\/multiedit\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\ndevel\/*\nnode\/*\/devel\nnode\/*\/devel\/*\ncomment\/*\/devel\ncomment\/*\/devel\/*\nuser\/*\/devel\nuser\/*\/devel\/*\ntaxonomy\/term\/*\/devel\ntaxonomy\/term\/*\/devel\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":["ru"],"ajaxCallback":"overlay-ajax"},"scroll_to_top":{"label":"\u0412\u0432\u0435\u0440\u0445"}},"merge":true},{"command":"insert","method":"prepend","selector":"#ng-wall-poster","data":"\u003Cdiv id=\u0022ng-wallpost-91\u0022 class=\u0022ng-wallpost odd clearfix\u0022\u003E\n\n\n\n\u003Cdiv class=\u0022pic\u0022\u003E\n\n\n\n \n\u003C\/div\u003E\n\u003Ca href=\u0022\/user\/1\u0022\u003E \u003Ch3\u003E \u0421\u0443\u043f\u0435\u0440\u0430\u0434\u043c\u0438\u043d\u043a\u0438\u043d\u0430 \u041c.\u0421. \u003C\/h3\u003E\u003C\/a\u003E\n\n\n\u003Cspan class=\u0022ng-status\u0022\u003E \n \u041d\u043e\u0432\u043e\u0435\u003C\/span\u003E\t\n\t\n \u003Cdiv class=\u0022submitted\u0022\u003E\n 16\/01\/2014 - 12:57 \u003C\/div\u003E\n\t\n\u003Cdiv class=\u0022content\u0022\u003E\n \u0441 \u003C\/div\u003E\n\n\u003Cdiv class=\u0022links\u0022\u003E\n \u003Ca href=\u0022\/ng_wall\/1\/91\/delete\/nojs\u0022 class=\u0022use-ajax\u0022 title=\u0022\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435?\u0022\u003E\u0423\u0434\u0430\u043b\u0438\u0442\u044c\u003C\/a\u003E\u003C\/div\u003E\n\n\u003C\/div\u003E\n","settings":null},{"command":"invoke","selector":"#ng-wall-reload-wrapper textarea","method":"val","arguments":[""]},{"command":"insert","method":"html","selector":"#ng-wall-message","data":"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e!","settings":null},{"command":"invoke","selector":"#ng-wall-message","method":"addClass","arguments":["messages status"]},{"command":"invoke","selector":"#ng-wall-message","method":"removeClass","arguments":["error"]},{"command":"invoke","selector":"#ng-wall-reload-wrapper textarea","method":"removeClass","arguments":["error"]}]
Комментарии
ЧЗХ?
Решила сама, отключила в модуле для smtp отправки писем debagger!
Прошу прощения, что отвлекла,
«правильно поставленный вопрос- половина ответа»