Created
August 20, 2017 20:19
-
-
Save gmemstr/c19f58f43e5ed3c7a5d6a0ae31a18008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+// Converts ajax POST to JavaScript object | |
+var BodyToObject = function(body) { | |
+ var res = new Object; | |
+ body = body.split("&"); // param1=X,param2=X | |
+ console.log(body); | |
+ for (var i = body.length - 1; i >= 0; i--) { | |
+ var vals = body[i].split("="); // param2,X,param1,X | |
+ for (var k = vals.length - 2; k >= 0; k--) { | |
+ res[vals[k]] = vals[k + 1] // *hopefully* {param1:X,param2:X} | |
+ } | |
+ } | |
+ return res; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment