2015-03-23 13:24:14
Ajax Doesnt Pass Value to PHP SESSION
I'm trying to create a contact form on top of the page and want to have the page stays at what it is before users submitting the form.
Now I'm using AJax to call the "send_email.php", which is processing email sending staff. However the problem is the session values are not passed to the send_email.php.
I tried the following code, it doesn't work:
$('#contextual_help_form').on('submit', function(e) {
$.ajax({
type: "POST",
url: '/send_email.php',
data: $('#contextual_help_form').serialize(),
success:function(data) {
console.log(data);
}
});
return false;
});
I also tried to replace " return false;" with "e.preventDefault();", it doesn't work.
I added session_start() on the top of the page and am sure there's no extra space between <?php or on the top of the file.
Could you please help me with it? It's also OK if there's another way to do the email sending without refreshing the page.