Html 使用POST方法将数据从Dart发送到PHP
我正在尝试将一些数据从Dart发送到PHP。。。 这是我用来从Dart发送数据的代码:Html 使用POST方法将数据从Dart发送到PHP,html,dart,Html,Dart,我正在尝试将一些数据从Dart发送到PHP。。。 这是我用来从Dart发送数据的代码: button.onClick.listen((e) { var req = new HttpRequest(); req.onReadyStateChange.listen((HttpRequestProgressEvent e) { if (req.readyState == HttpRequest.DONE) { print('Data submitted!');
button.onClick.listen((e) {
var req = new HttpRequest();
req.onReadyStateChange.listen((HttpRequestProgressEvent e) {
if (req.readyState == HttpRequest.DONE) {
print('Data submitted!');
}
});
req.open('POST', form.action);
req.send('hello from dart');
});
在我的PHP文件中,我试图使用从dart发送的字符串,但count($\u POST)返回0$_帖子似乎是空的
Dart代码确实会触发php脚本并打印“数据提交”…这实际上与您的php配置有关。您可以使用PHP的保留变量访问POST'd数据:但是首选方法是使用我对Dart非常陌生,但是您可以在send中使用FormData。因此,一个快速而肮脏的方法可能是
var data_form = new FormData(query('#My_form'));
button.onClick.listen((e){
var request = new HttpRequest():
request.open('POST', 'http://Localhost/form_data.php');
request.send(data_form);