Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Created June 15, 2011 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjmiller/1027681 to your computer and use it in GitHub Desktop.
Save brianjmiller/1027681 to your computer and use it in GitHub Desktop.
Y.io with JSON parse
Y.io(
"/manage/Countries/options?_format=json",
{
on: {
success: Y.bind(
function (txnId, response) {
var new_data;
try {
new_data = Y.JSON.parse(response.responseText);
}
catch (e) {
Y.log(Clazz.NAME + "::_onRequestSuccess - Can't parse JSON: " + e, "error");
return;
}
Y.log(Clazz.NAME + "::initializer - io success - new_data.options: " + Y.dump(new_data.options));
this.set("countries", new_data.options);
},
this
),
failure: Y.bind(
function (txnId, response) {
// TODO: what do we want to do in this case?
},
this
)
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment