function sendTNTRequest(request_data, target) { $.getJSON("http://<my_domain>/<my_script>/?data=" + $.jSONToString(request_data) + "&callback=?", function(quote) { if (quote.error) { showError(ERROR + "\n\nReason: " + quote.error) } else { // this request is either from the cart page if ($(target).attr("id") == "cart-shipping-cost") { $(target).html("$" + quote.cost) } // ...or the checkout page else { // update the shipping cost FC.checkout.config.orderFlatRateShipping = quote.cost // display the new order total FC.checkout.updatePrice(-1) } } }) }