changeset 9:5068e7dc31c1 draft

add post.html and postscript.js
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Fri, 21 Sep 2012 00:57:08 +0900
parents a468d9c5171c
children 6fdf1b084a00
files post.html postscript.js
diffstat 2 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/post.html	Fri Sep 21 00:57:08 2012 +0900
@@ -0,0 +1,14 @@
+<html>
+  <head>
+    <script src="postscript.js"></script>
+
+  </head>
+  <body>
+    <form id="form_id" action="postURL" method="post">
+      <input type="text" name="text">
+      <input type="submit" onclick="stringPost(); return false" value="send">
+    </form>
+    <textarea id="textarea"></textarea>
+
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/postscript.js	Fri Sep 21 00:57:08 2012 +0900
@@ -0,0 +1,26 @@
+function XMLRequest() {
+    if (this.XMLHttpRequest) {
+        return new XMLHttpRequest();
+    } else {
+        alert("Your browser not support XMLHttppRequest ");
+    }
+}
+
+function stringPost() {
+    var form = document.getElementById("form_id");
+    var postString = form.text.value;
+    var obj = XMLRequest();
+    obj.onreadystatechange = function() {
+        if (obj.readyState == 4 && obj.status == 200) {
+	    document.getElementById("textarea").value = obj.responseText;
+        }
+    }
+    var URL = 'http://localhost:9000/db/data/node';
+    obj.abort();
+    obj.open('POST',URL, true);
+<!--
+    obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
+-->
+    obj.send();
+    var resStr = obj.responseText;
+}