Skip to content

Instantly share code, notes, and snippets.

@HendrikHaase
Created July 11, 2014 07:15
Show Gist options
  • Select an option

  • Save HendrikHaase/eb1eb3d071ea62345c92 to your computer and use it in GitHub Desktop.

Select an option

Save HendrikHaase/eb1eb3d071ea62345c92 to your computer and use it in GitHub Desktop.
function ajaxreturnafterfunctionreturn(navObject) {
var foo = [];
var j = 0;
var jsonconfig = getConfig(navObject);
$.ajax({
type: 'POST',
url: '/api/select',
data: JSON.stringify({
"table": jsonconfig.table,
"fields": _.map(jsonconfig.fields, function(f) {
return f.field;
}),
"filters": jsonconfig.filters
}),
contentType: 'application/json',
dataType: 'json',
success: function(rows) {
_.each(rows, function(r) {
foo[j] = (r);
j++;
_.each(jsonconfig.fields, function(f) {
//console.log(r[f.field]);
});
});
console.log("j.ajax: " + j);
console.log("foo.ajax: " + foo);
},
error: function(e) {
console.log(e);
}
});
console.log("j.after: " + j);
console.log("foo.after: " + foo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment