Welcome Guest, Not a member yet? Register   Sign In
Passing values to a controller through jquery ajax post
#5

[eluser]vintage75[/eluser]
I tried putting this code at the top of my send_email function:

Code:
if(empty($_SERVER['CONTENT_TYPE'])){
     $type = "application/x-www-form-urlencoded";
     $_SERVER['CONTENT_TYPE'] = $type;
}

No luck though, same result. It doesn't seem like it's a data type issue to me.

I just tried using the same jquery function, just changed the post to location (js/send.php) to a new php file I made for test purposes and it works perfectly. So somehow when posting to the controller, the values are getting lost. So it's a CodeIgniter problem.

Code:
if (hasError == false){
        $("#"+id+" .box").html("<img  110px;' alt='sending...' src='/images/sending.gif'/>");
        $.post("/js/send.php",
               {
                   email: emailFromVal,
                   message: messageToVal              
                },
         function(data){
            
             $("#"+id+" .box").html("<p>"+data+"</p>");
         }
        
        );
        return true;
    } else {
        return false;
    }

Here is the send.php file

Code:
&lt;?php
$emailFrom = $_POST['email'];
$mailFrom = 'Test Test';
$subject = 'Test Mail';
$message = $_POST['message'];
$header =     "From: ".$mailFrom." ".$emailFrom."\r\n".
            "Reply-To: ".$emailFrom;
            
if (mail('<email>', $subject, $message, $header,'-f <email>')){
    echo "Your email has been sent!";
} else {
    echo "There was an error sending this message.";
}
?&gt;


Messages In This Thread
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 10:32 AM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 12:33 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 12:35 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 12:44 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 01:06 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 02:36 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 03:38 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-16-2010, 07:54 PM
Passing values to a controller through jquery ajax post - by El Forum - 07-18-2010, 05:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB