'use strict'; $(function () { $('#businessRenewBtn').click(function (event) { $('#renewContractSubmitButton').click(); }); $("#costCenterSelect").on('change', function() { var custCode = $(this).val(); $.ajax({ dataType: "json", type: "POST", url: "/blocks/myProfile/loyalty/renewContractJson.jsp?custCode=" + custCode, success: function(data){ $("#eligibleNumbers").find("tr").remove(); $.each(data.contracts, function(i) { $('#eligibleNumbers').append($("").html("" + data.contracts[i].msisdn + "" + data.contracts[i].status + "" + data.contracts[i].renewalEligibilityDate + "")); }); }, }); }); }); function clickEventForRenewContract (linkId) { //ajax synchronous call: #selectEligibleContractForm if ($('#selectEligibleContractForm').length) { $('#selectEligibleContractForm').ajaxForm({ async: false, dataType: 'json', success: function (data) { var txt = JSON.stringify(data); var ret = jQuery.parseJSON(txt); if (!ret.isStatusSuccess) { console.log('Failed to select eligible MSISDN!'); // We should probably show some error message here and prevent going to configurator. } }, error: function (jqXHR, textStatus, errorThrown) { console.log(textStatus + ": " + errorThrown); } }); $('#selectEligibleContractFormSubmit').click(); } if( document.createEvent ) { var clickEvent = document.createEvent('MouseEvents'); clickEvent.initEvent( "click", true, true ); if (document.getElementById(linkId) != null) { document.getElementById(linkId).dispatchEvent(clickEvent); } } else if( document.createEventObject ) { // for IE var clickEvent = document.createEventObject(); document.getElementById(linkId).fireEvent( 'onclick', clickEvent ); } }