$http angularjs php响应
对angularjs来说很新,但已经做了一些研究。 我正在发出以下$http post请求:$http angularjs php响应,php,angularjs,json,http,Php,Angularjs,Json,Http,对angularjs来说很新,但已经做了一些研究。 我正在发出以下$http post请求: $scope.onClick2 = function () { var myRequest = {}; myRequest = {}; myRequest.ServiceType = "SearchExams"; myRequest.SessionId = 'SessionlessRequest
$scope.onClick2 = function () {
var myRequest = {};
myRequest = {};
myRequest.ServiceType = "SearchExams";
myRequest.SessionId = 'SessionlessRequest';
myRequest.Compression = 'no';
myRequest.Parameters = {};
myRequest.Parameters.Status = ['30', '40'];
myRequest = JSON.stringify(myRequest);
var request = $http({
method: 'POST',
url: 'http://localhost/request.php',
data: 'data=' + myRequest,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
})
};
php处理请求并发送回json响应。
然而,我在chrome的response选项卡和fiddler中看到原始请求也在响应中。见下文:
Array
(
[data] => {"ServiceType":"SearchExams","SessionId":"SessionlessRequest","Compression":"no","Parameters":{"Status":["30","40"]}}
)
{"Error":false,"ErrorMessage":null,"Data":[{"ExamID":1,"A.......
我只希望返回最后一行({“Error”:false,“ErrorMessage”:null,“Data”:[{“ExamID”:1,“A…”),看看我的request.php应该返回什么
我错过什么了吗
谢谢,很抱歉耽误了大家的时间。
我的php代码中确实有一个错误。那么你的php代码在哪里?我们无法从你的JS中看出php返回不同的内容。这部分内容与我的php代码Logger::LogDebug(“response:$response”);这部分内容在日志中:2016-01-19 14:44:09-DEBUG-->[::1][[请求]响应:{“错误”:false,“ErrorMessage”:null,“数据”:[{”ExamID“:1,“……显然,删除日志记录、打印或您在controllerSorry dfsq中使用的任何东西,我不明白您的要求。抱歉,各位,我自己已经修复了它,我的php代码中确实有一个错误。