I have been looking for hours, I know javascript is the client side and php is the server side and for communicating they need to use POST
or whatever.
I have made this code in javascript first to retrieve the value i want and send it to php with jquery.
function getGroupName(test){
var groupName = ($(test).parent().attr('id'));
$.post("setGroup.php",{ groupName:groupName } ,function(data) {
if(data == 'yes'){
<?php
$testing = $_SESSION['currentGroup'];
$tsql2 = "select emailName,email from privacyEmails where tagID = '$tagid' and userEmail = '$testmail' and circleName = '$testing'";
$stmt2 = sqlsrv_query( $conn, $tsql2);
$order = 0;
$emailNameT = "";
$NameT = "";
while( $row = sqlsrv_fetch_array( $stmt2, SQLSRV_FETCH_NUMERIC))
{
$emailNameT = $row[0];
$NameT = $row[1];
?>
makeEditPeople('<?php echo $NameT ?>','<?php echo $emailNameT ?>','<?php echo $order ?>');
<?php
$order = $order +1;
}
?>
}
});
}
this is the php code (setGroup.php
) to get the $testing
:
<?php
include "connectionString.php";
session_start();
$groupName = $_POST['groupName'];
$_SESSION['currentGroup'] = $groupName;
echo "yes";
?>
Please note that the makeEditPeople()
in the js is a method that append the user received in parameter into a table which works well.
My problem is : I want to send a javascript value (groupName
) to SESSION
value in php throught jquery $Post
, then in the same time, I want to retrieve it without refreshing the page. Is that possible?