$(document).ready(function() { $("#auction_timer").countdown({ until: new Date("Dec 31, 2015 12:46:00 -0600"), //serverSync: serverTime, compact: true, layout: " {dn} days {hnn}{sep}{mnn}{sep}{snn}", onExpiry: liftOff }); }); /*---------------------------*/ function liftOff() { submit_auction_form('auctionDetail.php?action=auction_ended&auction_id=12&product_id=', 'POST', {'action':'auction_ended', 'auction_id':'12', 'product_id':''}); $('#product_bid_div').hide(); } /*---------------------------*/ function serverTime() { var time = null; $.ajax({ url: '../_assets/includes/serverTime.php', async: false, dataType: 'text', success: function (text) { time = new Date(text); }, error: function (http, message, exc) { time = new Date(); } }); return time; } /*---------------------------*/ function submit_auction_form(path, method, params ) { method = method || "post"; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); //Move the submit function to another variable //so that it doesn't get overwritten. form._submit_function_ = form.submit; for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form._submit_function_(); }