Skip to content

Instantly share code, notes, and snippets.

@pjhoberman
Created February 9, 2011 22:05
Show Gist options
  • Save pjhoberman/819410 to your computer and use it in GitHub Desktop.
Save pjhoberman/819410 to your computer and use it in GitHub Desktop.
// ajax to html what what
$.extend( {
updateBlock: function(url, options, callback){
var defaults = {
round:false
}; // defaults
options = $.extend({}, defaults, options || {});
$.getJSON(url, function(data, these_options){
var r = data.output; // r for record
for (var key in r) {
if (r.hasOwnProperty(key)) {
if( typeof r[key] == 'object' ) { // units and values
if( options.round )
round($( '#' + key ).text( quantity(r[key])),1);
else
$( '#' + key ).text( quantity(r[key]));
} // if
else
{
if( r[key] === '' && typeof r[key] == 'string' ) // for blank strings
r[key] = '--';
if( options.round )
round( $( '#' + key ).text( r[key] ), 1 );
else
$( '#' + key ).text( r[key] );
} // else
} // if
} // for
if( typeof callback == 'function' )
callback.call(this, data);
}); // get
},
completelyDifferentFunction: function( other, options, entirely){
}
}); // extend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment