title: DataTables sAjaxSource Json higlight search data
body: <p>I am trying to implement search highlight on data table ( JSON data is coming and filling up the table from serverside through "sAjaxSource"), Please see the below code for details.</p>
  
  <p>search is working by default, BUT highlight is not working at all.</p>
  
  <p><strong>I alerted data of  searchTxt+=$('#search_input').val();       alert("txt" + searchTxt);
  and alert is displaying search input box text.
  Alert for " alert(""+ aData[j]); " displaying "undefined rather than column data and highlight is not working.</strong></p>
  
  <p>Could anyone shed some light on this ?</p>
  
  <p>Thank you,
  Sri</p>
  
  <pre><code>jQuery(document).ready(function() {
    var oTable = jQuery('#example').dataTable({
   "sDom": '&lt;"#table_header"&lt;"#inner_table_header"&lt;"filtertx"&gt;fCT&lt;"filterbtn"&gt;&gt;&gt;tipl',
    "sAjaxSource": ajaxURL,
   "bDeferRender": true,
   "bProcessing" :  true,
   "bJQueryUI": true,  
   "sScrollY": 500,
   "aaSorting": [[0, 'desc']],
   "aoColumns": [
    { "mData": "name" },
    { "mData": "flag" }
   ],
   "oSearch": {"sSearch": "", 
      "bSmart": true,
      "bRegex": false},
  "sPaginationType": "paginate",
  "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
      $(nRow).addClass('clickable');  
      $(nRow).attr('onClick', "editPopup(" + aData['conditionId'] + ")");
  },
  "fnDrawCallback": function( oSettings ) {
     $(expandWrapper);
   }
   });
  
     $("#example_filter label").attr("for", "search_input");
       $("#example_filter input").attr({
           "id": "search_input",
           "placeholder" : 'search'
      }); 
      oTable.fnSearchHighlighting();
    });
  
  jQuery.fn.dataTableExt.oApi.fnSearchHighlighting = function(oSettings) {
  
          oSettings.oPreviousSearch.oSearchCaches = {};
          oSettings.oApi._fnCallbackReg( oSettings, 'aoRowCallback', function( nRow, aData,              iDisplayIndex, iDisplayIndexFull) {
                          var searchStrings = [];
                          var oApi = this.oApi;
                          var cache = oSettings.oPreviousSearch.oSearchCaches;
                      // Global search string
                      // If there is a global search string, add it to the search string array
                      if (oSettings.oPreviousSearch.sSearch) {
                          searchStrings.push(oSettings.oPreviousSearch.sSearch);
                      }
                      // Individual column search option object
          // If there are individual column search strings, add them to the search string array
  
      searchTxt=$('#filter_input input[type="text"]').val();
      searchTxt+=$('#search_input').val();
  
      alert("txt" + searchTxt);
      if ((oSettings.aoPreSearchCols) &amp;&amp; (oSettings.aoPreSearchCols.length &gt; 0)) {
          for (var i in oSettings.aoPreSearchCols) {
              if (oSettings.aoPreSearchCols[i].sSearch) {
                  searchStrings.push(searchTxt);
              }
          }
      }
      // Create the regex built from one or more search string and cache as necessary
      if (searchStrings.length &gt; 0) {
          var sSregex = searchStrings.join("|");
          if (!cache[sSregex]) {
              // This regex will avoid in HTML matches
              cache[sSregex] = new RegExp("("+escapeRegExpSpecialChars(sSregex)+")(?!([^&lt;]+)?&gt;)", 'i');
          }
          var regex = cache[sSregex];
      }
      // Loop through the rows/fields for matches
      jQuery('td', nRow).each( function(i) {
  
      // Take into account that ColVis may be in use
      var j = oApi._fnVisibleToColumnIndex( oSettings,i);
      // Only try to highlight if the cell is not empty or null
  
      alert(""+ aData[j]);
  
      if (aData[j]) {
      // If there is a search string try to match
      if ((typeof sSregex !== 'undefined') &amp;&amp; (sSregex)) {
          alert("here");
          this.innerHTML = aData[j].replace( regex, function(matched) {
          return "&lt;span class='filterMatches'&gt;"+matched+"&lt;/span&gt;";
          });
      }
      // Otherwise reset to a clean string
      else {
          this.innerHTML = aData[j];
      }
      }
      });
      return nRow;
      }, 'row-highlight');
      return this;
      };
  </code></pre>