ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Ajax Doesnt Pass Value to PHP SESSION


  • 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.

  • 2015-03-25 06:55:42

    Re: Ajax Doesn't Pass Value to PHP SESSION

    Process this as PHP and and the full URL to send_mail.php

    Something like
    <?php $SERVER['http_host'].$_base_href?>"send_mail.php"