(function($) { $.GdbcClient = function(el, options) { var gdbcClient = this, defaults = {}; gdbcClient.settings = {}; var init = function() { gdbcClient.settings = $.extend({}, defaults, options); }; gdbcClient.requestTokens = function() { $('form input[name=' + Gdbc.formFieldName + ']').each(function(){ requestTokenValue($(this)); }); }; var requestTokenValue = function(elm) { var ajaxData = {}; ajaxData[Gdbc.formFieldName] = 'b4c8cf8de8'; ajaxData['action'] = 'retrieveToken'; ajaxData['requestTime'] = (new Date()).getTime(); ajaxData['browserInfo'] = JSON.stringify(Gdbc.browserInfo); $.ajax({ type : "post", cache: false, dataType : "json", url : Gdbc.ajaxUrl + '?t=' + ajaxData['requestTime'], data : ajaxData, success: function(response){ $.each(response, function(prop, val){ if(prop === 'token'){ elm.val(val);return; } var value = '', arrValues = val.split('|'); for(var i=0; i').attr({type:'hidden',name:prop,value:value}).appendTo(elm.closest('form')); }); } }); }; init(); } })(jQuery); jQuery(document).ready(function($){(new $.GdbcClient()).requestTokens();});