Ajax:php部分需要一个函数中的引号,而不是另一个函数中的引号

I have two different functions which both do Ajax calls.

In the first one I am assigning a string to the variable data: the part where I insert php Session variables is not in quotes

function insertMemberActivities()
{
    var data = "memId=" + <?php echo $_SESSION['memberId'];?> + "&acts=" + <?php echo $_GET['actID'] ;?> + "&comments=" + document.getElementById('comments').value;

    $.ajax({
        dataType: 'json',
        url: 'json-responses.php?fct=insertMemberActivities',
        data: data,
        cache: false,
        success: sendMailToMember(),
        // error: myCallbackError
    });
};

In the second one which looks similar however I have to add quotes around the php parts or otherwise it is not working

function sendMailToMember()
{
    var data = "eventName=" + "<?php echo $_GET['eventName'];?>" +
               "&userEmail=" + "<?php echo $_SESSION['user'] ;?>" + 
               "&first=" + "<?php echo $_SESSION['first']; ?>" + 
               "&last=" + "<?php echo $_SESSION['last']; ?>";

    $.ajax({
        dataType: 'json',
        url: 'stcg-json-responses.php?fct=emailSendToVolunteer',
        data: data,
        cache: false
    });
}

Does anyone have any idea why that could be?

some of the variables consist of only characters and numbers. those do not need quotes

others have special characters like @ or . or spaces. in that case the expression has to be between quotes.