【问题标题】:How do I POST urlencoded form data with HTTP?如何使用 HTTP POST urlencoded 表单数据?
【发布时间】:2017-11-22 08:55:23
【问题描述】:

我想将数据从 Ionic Form 传递到 Php 文件到 MySql 数据库。我对此完全陌生... 这是我将数据从 Ionic Form 传递到 Php 文件的代码

Please check this link for code

我尝试使用警报调试我的代码

alert(url); //Output: http://localhost/ionic-php-sql/manage-data.php
alert(body); //Output: key=create&name=Test&description=Test
alert(options); //[object Object]

每当我发出警报(选项)时,它就会显示 [object Object]。 (我想这是不正确的或有一些错误)。 我尝试将 alert() 放入

 this.http.post(url, body, { headers: headers }).subscribe((data) =>{}

然后它不显示警报弹出窗口。 请检查代码并告诉我是否有任何错误/更改。 提前谢谢你。

【问题讨论】:

  • 这个问题的答案是here

标签: php mysql angular ionic-framework http-post


【解决方案1】:

像这样使用它:

alert(JSON.stringify(options));

警报在警报框中不显示object,它只支持string类型。

我建议你使用console.log(options),你可以在浏览器控制台中看到它们,任何类型。

console.log() 打印所有类型的数据。

【讨论】:

  • 谢谢。现在它显示 => {"method":null,"headers":{"Content-Type":["application/x-www-form-urlencoded; charset=UTF-8"]},"body":null ,"url":null,"withCredentials":null,"responseType":null} 请检查代码是否有误或部分错误
猜你喜欢
  • 2016-11-21
  • 2017-08-29
  • 2018-08-16
  • 2018-08-18
  • 2021-06-30
  • 2013-11-02
  • 1970-01-01
相关资源
最近更新 更多