php-json:encode在服务器上的angular控制器上的http调用中返回undefined,但在localh
php json:encode returning undefined on http call on angular controller on server but works well on the localhost
php-json:encode在服务器上的angular控制器上的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;
对于ajax调用,这样需要将头设置为application/json,这样javascript就可以轻松读取它,并且还需要在与ajax相关的API设计中将错误报告为false
<?php
error_reporting(0);
...
...
...
header('Content-Type:application/json;');
echo $json_response;
这个输出很容易被javascript 读取
相关文章:
- RequireJS向模块传递配置总是返回undefined
- JSON数组数据返回Undefined
- JavaScript”;.方法“;返回undefined
- jQuery可以't获取data-*属性值,返回undefined
- Javascript/JSON警报返回Undefined
- Javascript:firstChild对象返回undefined
- 当尝试使用ajax读取文件时,变量返回undefined
- 如何避免JSON.stringify在特殊情况下返回undefined,从而为JSON.parse创建字符串失败
- 使用谷歌地图:一个返回undefined的自定义javascript函数
- Json在nodeJs和AngularJs中返回undefined
- 为什么像 Firefox 和 Chrome 控制台中的 '}{' 这样的结构会返回 'undefined'?
- 使用 HTML 和 JavaScript 从表单访问值时返回 undefined
- 在 CoffeeScript 中,当尝试调用类中的方法 (@_methodName) 时,它会返回 undefined
- 解析承诺'当'返回undefined(Javascript)
- NodeJS:zlib.gunzip(body)错误地返回“undefined”
- window.open在chrome扩展中返回undefined
- jQuery.pr()返回undefined,而.attr()对数据-*的作用与预期一样
- 正在读取嵌套json,jquery返回undefined
- IIFE是否总是返回undefined
- $timeout包装$http.post返回undefined而不是promise