R
R
Roman-OverOffers2014-02-14 13:02:05
JavaScript
Roman-OverOffers, 2014-02-14 13:02:05

How to find error in JS (dataTables)?

Good afternoon, the console swears at
Uncaught SyntaxError: Unexpected token ) stattables.js:168
I selected the line.

var stat_options = $.extend({'sAjaxSource':"/dashboard/graph/", "aoColumns": [
 			{ "mData": "date" },
 			
     //{"mData":"clicks"}, 
{ "mData":"unique_clicks" }, 

{ "mData":"events_count" },
{ "mData":"approved" },
{ "mData":"pending" },
{ "mData":"rejected" }, 

{ "mData":"cpc" }, 
{ "mData":"ltr" }, 
{ "mData":"approval_rate" }, 
//{"mData":"total_revenue"}, 
//{"mData":"rejected_revenue"},
{ "mData":"pending_revenue" },
{ "mData":"approved_revenue" }  
], "fnFooterCallback": function( nRow, aaData, iStart, iEnd, aiDisplay ) {
                var iTotal = 0
                var iTotal2 = 0
                for ( var i=0 ; i<aaData.length ; i++ )
                {
                    iTotal += aaData[i][9]*1;
                    iTotal2 += aaData[i][10]*1;
                }
             
                var nCells = nRow.getElementsByTagName('th');
                nCells[9].innerHTML = parseInt(iTotal);
                nCells[10].innerHTML = parseInt(iTotal2);
<b>             });</b>
                 },tables_options);


How correctly it was necessary to close the function?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
aplic, 2014-02-14
@aplic

Put away ); after the body of the function (and <b> of course).

A
Artur Smirnov, 2014-02-14
@artursmirnov

You have some kind of perfect hell in formatting. Good code formatting is the key to avoiding syntax errors.

var stat_options = $.extend({
  "sAjaxSource": "/dashboard/graph/", 
  "aoColumns": [
    { "mData": "date" }, 			
    // {"mData":"clicks"}, 
    { "mData":"unique_clicks" }, 
    { "mData":"events_count" },
    { "mData":"approved" },
    { "mData":"pending" },
    { "mData":"rejected" }, 
    { "mData":"cpc" }, 
    { "mData":"ltr" }, 
    { "mData":"approval_rate" }, 
    // {"mData":"total_revenue"}, 
    // {"mData":"rejected_revenue"},
    { "mData":"pending_revenue" },
    { "mData":"approved_revenue" }  
  ], 
  "fnFooterCallback": function( nRow, aaData, iStart, iEnd, aiDisplay ) {
    var iTotal = 0;
    var iTotal2 = 0;
    for ( var i=0 ; i<aaData.length ; i++ ) {
      iTotal += aaData[i][9]*1;
      iTotal2 += aaData[i][10]*1;
    }     
    var nCells = nRow.getElementsByTagName('th');
    nCells[9].innerHTML = parseInt(iTotal);
    nCells[10].innerHTML = parseInt(iTotal2);
  });
}, tables_options);

R
Roman-OverOffers, 2014-02-14
@Roman-OverOffers

Outputs NaN :(
ff193c681ddab88461a8ca41b9b36f78.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question