import 'dart:html';
void main() {
var data = { 'firstName' : 'John', 'lastName' : 'CarMark' };
HttpRequest.postFormData('http://localhost:3000/pt', data).then((HttpRequest resp) {
// Do something with the response.
querySelector('#post_cb').text = "从服务器返回的:" + resp.responseText;
});
}
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>posttest</title>
<script async src="main.dart" type="application/dart"></script>
</head>
<body>
<div id="post_cb"></div>
</body>
</html>
结果:(注意 跨域问题)