View Single Post
Old 11-01-2012, 04:50 AM   PM User | #1
FowlerS47
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
FowlerS47 is an unknown quantity at this point
Cleaner Code - Pseudocode

I am tinkering with this code snippet and trying to determine a cleaner better way to use my logic with javascript. I am relative beginner, so would appreciate any help.

<script>// JavaScript Document
var Alpha = function() {
this.itemOne = 1;
this.itemTwo = 2;

this.doSomething = function(withThis) {
$.post("/post/url", { data: withThis },
function(result) {
this.itemOne = result.resultOne;
this.itemTwo = result.resultTwo;
});
};
this.doSomethingElse = function(withThese) {
for (var i = 0; i < Things.length; i++) {
$.each(Things[i].subItems, function(subItem) {
};
};
$.post("/post/url2", { data: withThese.postData},this.postResponse);
};
};

Alpha.prototype.postResponse = function(data) {
this.doSomething(data);
};

</script>
FowlerS47 is offline   Reply With Quote