[英]php json:encode returning undefined on http call on angular controller on server but works well on the localhost
php json:encode returning undefined on http call on angular controller on server but works well on the localhost. php json:encode在服务器上的角度控制器上的http调用上返回undefined,但在localhost上运行良好。
if( hash_equals($hashed_password, crypt($password, $hashed_password))){
$pass = "true";
$result = array('pass' => $pass, 'FirstName' => $f_name,
'LastName' => $l_name,'id' => $id);
}else{
$pass = False;
$result = array('pass' => $pass, 'FirstName' => "", 'LastName' => ""
, 'id' => $id);
}
$json_response = json_encode($result);
echo $json_response;
For ajax calls, such as this requires the header to be set as application/json, so javascript can easily read it, and also need to make error reporting to false in ajax related API designs 对于诸如此类的ajax调用,要求将标头设置为application / json,因此javascript可以轻松读取它,并且还需要在与ajax相关的API设计中将错误报告报告为false
<?php
error_reporting(0);
...
...
...
header('Content-Type:application/json;');
echo $json_response;
this output is easily readable by javascript 此输出很容易由javascript读取
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.