Permalink
Browse files

after ajax hell, figured out that JSON.parse cant handle length <= fo…

…r SMEMBERS, since undefined comes across as a string instead of just null. so you have to remove that last item. that took fucking forever.
  • Loading branch information...
imgntn committed Apr 18, 2012
1 parent db925fb commit ef396349a355ae944be1787081dd2eab62185644
Showing with 45 additions and 35 deletions.
  1. +2 −4 index.html
  2. +43 −31 onDeath.js
View
@@ -22,8 +22,7 @@
<!--This is where we load the island and the objects specific to it-->
<script src="bethereLoader.js"></script>
<script src="scene2Loader.js"></script>
- <script src="onDeath.js"></script>
-
+ <script src="onDeath.js"></script>
<script src='threex.domevent.js'></script>
<script src='threex.domevent.object3d.js'></script>
<style>
@@ -270,8 +269,7 @@
}
- deathTreeArrayGet();
-
+
/*
var sessionArrayFetch, sessionArrayParse, sessionArrayStaging;
View
@@ -1,4 +1,4 @@
-
+/*
function onDeath () {
@@ -11,47 +11,59 @@ function addDeathTree()
{
- $.get("http://bethere.io:7379/SADD/deathTrees/"+JSON.stringify(scene2treeContainer2.position))
+ $.get("http://bethere.io:7379/SADD/deathTrees/"+JSON.stringify(scene2treeContainer2.position));
}
+*/
var deathTreeArrayFetch, deathTreeArrayParse, deathTreeArrayStaging;
-var deathTreeArray = [];
+var deathTreeArray = [];
+var deathTreePositionArray = [];
+
+var length, i, temp;
+/*
+deathTreeArrayFetch = $.get("http://bethere.io:7379/SMEMBERS/deathTrees", function() {
+deathTreeArrayParse = JSON.parse(deathTreeArrayFetch.responseText);
+}).error(function() { console.log("error"); });
-function deathTreeArrayGet () {
-
- deathTreeArrayFetch = $.get("http://bethere.io:7379/SMEMBERS/deathTrees")
- .success(function (){
+deathTreeArrayFetch.success(function () {
+ length = deathTreeArrayParse.SMEMBERS.length;
+ for (i=0; i<= length; i++){
- deathTreeArrayParse = JSON.parse(deathTreeArrayFetch.responseText);
- deathTreeArrayStaging = deathTreeArrayParse.SMEMBERS;
- deathTreeArray.push(deathTreeArrayStaging);
+temp=JSON.parse(deathTreeArrayParse.SMEMBERS[i]);
- deathTreeJSON();
-
- });
-
-
-}
-
-var i;
-var deathTreePositionArray = [];
-var temp;
-
-function deathTreeJSON()
-{
- for (i=0; i <= deathTreeArrayStaging.length ; i++)
- {
- temp = JSON.parse(deathTreeArray[0][i]);
deathTreePositionArray.push(temp);
- }
-}
-
-
-
+ console.log(temp);
+ }
+
+ });
+ */
+
+ deathTreeArrayFetch = $.ajax({
+ url: "http://bethere.io:7379/SMEMBERS/deathTrees",
+ context: document.body,
+ dataType: "json",
+ success: function(){
+ deathTreeArrayParse = JSON.parse(deathTreeArrayFetch.responseText);
+ length = deathTreeArrayParse.SMEMBERS.length;
+ for (i=0; i< length; i++){
+ temp = deathTreeArrayParse.SMEMBERS[i];
+ temp=JSON.parse(temp);
+ deathTreePositionArray.push(temp);
+ console.log(temp);
+ }
+ }
+
+ });
+
+ /*
+ $(document).ajaxError(function(e, xhr, settings, exception) {
+ alert('error in: ' + settings.url + ' \n'+'error:\n' + xhr.responseText );
+ });
+ */

0 comments on commit ef39634

Please sign in to comment.