php - Set Session Ajax Post -
anyway set session when remote login ajax .
this code
var result = null; var scripturl = "http://www.site.com/login.bs"; $.ajax({ url: scripturl, type: 'post', data: ({txttitle : 'tt1', txttext : 'tt2'}), datatype: 'json', async: false, success: function(data) { alert("success"); }, error: function (err) { alert("error"); } });
in target page when login session[user] set . when refresh page alert error .
target code
if($_post[txttitle]=='tt1' && $_post[txttext]=='tt2') { $_session[user]='ok'; }
on backend, javascript expecting sort of json response. datatype: 'json'
try:
header('content-type: application/json'); echo json_encode(array());
Comments
Post a Comment