function initMyAccountOverview() { // initCECreditHistory(); } function initCECreditHistory() { var tbl = $('#ce_credit_history_table').get(0); $('#ce_credit_history_period').change(function(){ if (this.value == '') return false; $.ajax({ 'url': 'ce_credit_history', data: { action: 'list', period: this.value }, beforeSend: function() { $('#ce_credit_history_table tr.data').remove(); $('#ce_credit_history_table td.ce_total_for_period').text(''); $('#ce_credit_history_table tr.loading').show(); }, dataType: 'json', error: function (request, textStatus, errorThrown) { $('#ce_credit_history_table tr.loading').hide(); //alert(textStatus +' ' + errorThrown); }, success: function(data) { $('#ce_credit_history_table tr.loading').hide(); if (typeof data.list == 'object') { var rowIndex = 2; for (var i in data.list) { var row = tbl.insertRow(rowIndex); row.className = 'data'; row.insertCell(0).appendChild(document.createTextNode(data.list[i].name)); var cell2 = row.insertCell(1); cell2.appendChild(document.createTextNode(data.list[i].credits)); cell2.style.textAlign = 'center'; rowIndex++; } if (!data.list.length) { var row = tbl.insertRow(rowIndex); row.className = 'data'; var cell = row.insertCell(0); cell.colSpan = 2; cell.style.textAlign = 'center'; cell.appendChild(document.createTextNode('Not Found')); } $('#ce_credit_history_table td.ce_total_for_period').text(data.total4period); } }, complete: function(request, textStatus) { } }); }).change(); }