ajax - file_get_contents (“php://input”) returning one long string -


i tryng send json on ajax php $_post has nothing , file_get_contents(“php://input”) returns 1 long string.

ajax code:

function senddata(userdata) {     alert(userdata);     $.ajax({         type: 'post',         url: 'testlogin.php',         datatype : 'json',         data: userdata,         success: function (msg) {         if (msg.error) {             alert("error:" + msg.msg);             showerror(msg.msg);         } else {  // send redirection page             alert("do here");         }     },     error : function (xmlhttprequest, textstatus, errorthrown) {         alert("ajaxerror:::" + textstatus + ":::" + errorthrown);     }     }); } 

the alert before ajax shows {"username":"user","password":"long hash here","op":"login"}

php code:

$user =  $_post('username'); $pass =  $_post["pass"];  $logstring = "user: ".$user.     " pass: ".$pass.     " server-request_method: ".$_server['request_method'].     " getfile: ".file_get_contents("php://input").       "*\n*\n"; // loging method  logme($logstring);  $returnmsg['msg']= $pass; $returnmsg['error'] = true; echo json_encode($returnmsg); 

this in log file

userpassserver-request_methodpostgetfileusernameasdpasswordcd8d627ab216cf7fa8992ca4ff36653ca6298566dc5f7d5cc9b96ecf8141c71boplogin

this @ return alert @ success in ajax error: null

i can't decode file_get_contents (“php://input”) because there no delimiters.

edit: logme function breaking logstring text. have fixed , have in logfile now. user: pass: server-request_method: post getfile: {"username":"asd","password":"cd8d627ab216cf7fa8992ca4ff36653ca6298566dc5f7d5cc9b96ecf8141c71b","op":"login"}

so should fine decode file_get_contents(“php://input”)

quention correct problem logging function. used in test because had available did not bother @ it. had cleanstring function in causing problems.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -