Skip to content

Instantly share code, notes, and snippets.

@travishaynes
Created January 28, 2012 19:46
Show Gist options
  • Save travishaynes/1695561 to your computer and use it in GitHub Desktop.
Save travishaynes/1695561 to your computer and use it in GitHub Desktop.
Pull shop's progress
var goal = 10000.00, // without a goal it will return the total purchase amount after the school percentage is applied
shop_id = 1195332, // this can be found in the top-right corner of the metafields app when logged into a shop
server = "http://localhost:3000"; // set this to the location of the metafields app
// get the shop's percentage using a JSONP AJAX call
// Note: This must use JSONP to avoid raising a cross domain access error
$.ajax({
url : server + "/progress/" + shop_id + ".json",
type : "get",
data : "goal=" + goal,
dataType: 'jsonp',
error : function(x,s,e){
throw e;
},
success : function(progress){
// this is just a sample. put the actual code
// to handle updating the progress bar here.
$("#progress_bar").css("width", (progress * 100) + "%");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment