dart系列(六) post請求

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.htmlhtml

<!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>


結果:(注意 跨域問題java

相關文章
相關標籤/搜索