0

これは私の JavaScript ビューであり、コントローラーが呼び出しています。JavaScript

$('#contact').submit(function(e){
e.preventDefault();
var name= $('input[name=contactname]').val();
var email= $('input[name=contactemail]').val();
var message= $('textarea[name=message]').val();
$.post("index.php/homepage/sendMail",{name:name, email:email, message:message},
function(){
   $('#contactUsMask').hide();
   $('#contactAckMask').show();
   });
});

コントローラ

$from = $_POST['email'];
$msg = $_POST['message'];
$name = $_POST['name'];

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);
$this->email->from($from, $name);
$this->email->to($to);
$this->email->subject($sub);
$this->email->message($msg);
if($this->email->send())
{
    return true;
}
else
{
    echo $this->email->print_debugger();
    return false;
}

投稿変数を読み取ることができません。助けてください。すべての努力に感謝

4

2 に答える 2

0

$("#testform").serialize()次のような投稿リクエストで使用してみてください

$('#contact').submit(function(e){
e.preventDefault();
$.post("index.php/homepage/sendMail",$("#contact").serialize(),
function(){
   $('#contactUsMask').hide();
   $('#contactAckMask').show();
   });
});

そしてあなたのコントローラーであなたは$this->input->post('email');電子メールの値を取得するために使用する必要があります..そして彼らが言ったようにやってみてくださいvar_dump($_POST)

于 2012-04-30T10:49:40.477 に答える
-1

このクロスサイトを実行している場合、.post は $.ajax のラッパーであるため、クロスサイトの問題が発生しています。

于 2012-04-30T10:47:50.027 に答える