Use JSON if at all possible. This way the browser will do the parsing for you, and you won’t have to do the post processing.
JSON from the server
{"content":
{"box": [
{"var1": "A1",
"var2": "B1",
"var3": "C1",
"var4": "D1"},
{"var1": "A2",
"var2": "B2",
"var3": "C2",
"var4": "D2"},
{"var1": "A3",
"var2": "B3",
"var3": "C3",
"var4": "D3"}]}}
Client javascript
var app = {
box: [],
init: function (file) {
var that = this;
$.ajax({
type: "GET",
url: file,
dataType: "json",
success: function(result) {
that.box = $.map(result.content.box, function(box, i) {
return new Box(i, box);
});
}
});
},
};