php - 如何解决flutter中的http请求错误
问题描述
我想从我自己的 PHP 文件中获取我的颤振应用程序中的数据,我在其中 echo jsonEncode(object);
但它给出以下错误:
Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28 get current
packages/http/src/browser_client.dart 71:22 <fn>
dart-sdk/lib/async/zone.dart 1612:54 runUnary
dart-sdk/lib/async/future_impl.dart 152:18 handleValue
dart-sdk/lib/async/future_impl.dart 704:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 733:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 530:7 [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
dart-sdk/lib/async/stream.dart 1219:7 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39 dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58 <fn>
at Object.createErrorWithStack (http://localhost:42101/dart_sdk.js:5347:12)
at Object._rethrow (http://localhost:42101/dart_sdk.js:39349:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:42101/dart_sdk.js:39343:13)
我的颤动代码在哪里给出错误..
getdata() async {
typesOfc = await http.get(Uri.parse("http://localhost:4545/"));
print(jsonDecode(typesOfc));
}
我正在使用 http 插件
我的PHP代码..
if($action == 'fetchData'){
$fetchQuery = "SELECT `NAME` , `PASSWORD` FROM `REGISTER`";
$FetchResult = mysqli_query($connectLhost , $fetchQuery);
$data = array();
if($FetchResult->num_rows > 0){
while($row = $FetchResult->fetch_assoc()){
$data[] = $row;
}
echo json_encode($data);
}else{
echo "Cant FetchData";
}
}
解决方案
推荐阅读
- c# - 如何在React组件类中绑定和调用c# obejct的方法
- reactjs - 父子组件之间的回调函数
- python - 如何对每个 n 数组值求和并将结果放入一个新数组中?
- microsoft-teams - 如何区分 Microsoft Teams 中的两个用户?
- python - 字典访问正在停止代码流
- node.js - 从 res.sendFile() 获取 req 对象
- asp.net - CORS İframe 无法使用 Asp.net SessionId
- python - Twisted AMP - 如何发送大于 64K 的值
- continuous-integration - 使用 CircleCI 在持续集成中运行测试脚本?
- java - 从本地系统进程启动交互式用户进程 - 获取错误代码 5