Now expecting 201 for new resource post
authorplehegar
Tue, 23 Aug 2011 17:03:22 -0400
changeset 31 81ebc65be8b6
parent 29 5a7b4f478677
child 33 dff4c2111c56
Now expecting 201 for new resource post
src/main/resources/scripts/tracker.js
--- a/src/main/resources/scripts/tracker.js	Tue Aug 23 16:43:08 2011 -0400
+++ b/src/main/resources/scripts/tracker.js	Tue Aug 23 17:03:22 2011 -0400
@@ -54,14 +54,14 @@
   },
 
   // send information to the server as JSON
-  sendAsJSON : function (uri, data) {
+  postNewResourceAsJSON : function (uri, data) {
     var xhr = new XMLHttpRequest;
 
     try {
     xhr.open("POST", uri, true);
     xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
-            if (xhr.status != 200) { // this needs to be 201
+            if (xhr.status != 201) {
               Util.log("xhr failed? [" + xhr.status + "] " + xhr.statusText);
             } else {
               Util.log("resource created at " + xhr.getResponseHeader("Location"));
@@ -320,7 +320,7 @@
   document.getElementById("start").textContent = "Start";
   document.getElementById("stop").disabled = true;
   Util.log("");
-  if (!Util.sendAsJSON(app.user.getPostRunURI(),app.currentActivity)) {      
+  if (!Util.postNewResourceAsJSON(app.user.getPostRunURI(),app.currentActivity)) {      
     if (!Util.store.set("track_gps_app", app.currentActivity)) {
       Util.log("[ERROR] Can't store the value " + e.code);
     }