I have this javascript to update a php session variable :
$(document).ready(function(){
$('#facebook_img').live('click',function(){
login_condetion = 1;
$.ajax({
type: "POST",
url: 'facebook_login_condition_variable.php',
data:{login_condetion:login_condetion},
dataType: "json",
success: function(data)
{
alert(123);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
/*alert(XMLHttpRequest);
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);*/
}
});
});
});
I print the session value before and after this code but it never change and when I alert responsText I get nothing and XMLHttpRequest gives me object object error .
This is my php code :
<?php
$temp = $_POST['login_condetion'];
if(!empty($temp) && $temp != 0)
{
$_SESSION['do_not_allow_auto_facebook_login'] = 1;
}
else
{
$_SESSION['do_not_allow_auto_facebook_login'] = 0;
}
$go = $_SESSION;
echo json_encode($go);
?>
Is there any problem with dataType of ajax function ? or it is a php session problem ? Please help me because I have been stuck here for long time.
.live()still using it,.on()is recommended.session_start()in the top of your PHP file?object objectIs not an error