Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IONAL 3$http.post返回为空_Javascript_Post_Ionic Framework_Ionic3 - Fatal编程技术网

Javascript IONAL 3$http.post返回为空

Javascript IONAL 3$http.post返回为空,javascript,post,ionic-framework,ionic3,Javascript,Post,Ionic Framework,Ionic3,我向php服务器发送了一篇带有Ionic的帖子。服务器响应为纯文本,但当尝试获取它时,对象为空 var response = $http.post('https://somthing.com', $rootScope.data); console.log(response); return response; 请求标头: Host: something.com User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/

我向php服务器发送了一篇带有Ionic的帖子。服务器响应为纯文本,但当尝试获取它时,对象为空

var response = $http.post('https://somthing.com', $rootScope.data);
console.log(response);
return response;
请求标头:

Host: something.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: http://localhost:8101/
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Content-Length: 137
Origin: http://localhost:8101
Connection: keep-alive
响应标题:

HTTP/1.1 200 OK
Date: Tue, 23 Oct 2018 06:39:22 GMT
Server: Apache
Cache-Control: no-cache, private
Content-Encoding: gzip
Vary: Accept-Encoding,User-Agent
Cache-Control: max-age=2592000
Expires: Thu, 22 Nov 2018 06:39:21 GMT
Keep-Alive: timeout=3, max=500
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

嗨,你能用
从'@ionic native/HTTP'导入{HTTP}吗
例如:


ionic cordova plugin add cordova plugin advanced http
npm install--save@ionic native/http
将其安装到应用程序文件夹中
constructor(... public http: HTTP){}

var url = 'https://somthing.com';
var data = {'form': form};
var headers = {'Accept' : 'application/x-www-form-urlencoded',
              'Content-Type' : 'application/x-www-form-urlencoded'};

this.http.post(url, data, headers).then((data) => {
  #actions...
}, error => {
  console.log(error);
  #actions... 
});