Skip to content

Instantly share code, notes, and snippets.

@walihassanjafferi
Created February 19, 2016 18:22
Show Gist options
  • Save walihassanjafferi/39159f218dc5f811c5b1 to your computer and use it in GitHub Desktop.
Save walihassanjafferi/39159f218dc5f811c5b1 to your computer and use it in GitHub Desktop.
Using Ajax Solr with JQuery Datatables
<div id="bkt_db_tables">
<h1>Games</h1>
<table id="example" class="display" width="100%">
<thead>
<tr>
<th>Game_ID</th>
<th>Home_Team</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Game_ID</th>
<th>Home_Team</th>
</tr>
</tfoot>
</table>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#example').dataTable( {
"processing":true,
"serverSide":true,
"bLengthChange": false,
"ajax": function ( data, callback, settings ) {
$.ajax( {
"url": "https://index.websolr.com/solr/xxxxxxxx/select/",
"data": $.extend( {}, data, {'wt':'json', 'q':'Game_ID:*', 'rows':'10'} ),
"dataType": "jsonp",
"jsonp":"json.wrf",
"success": function ( json ) {
var o = {
recordsTotal: json.response.numFound,
recordsFiltered: json.response.numFound,
data: json.response.docs
};
callback( o );
}
} );
},
"aoColumns": [
{"data" : "Game_ID" },
{"data" : "Home_Team" }
]
});
});
</script>
@vikash1kumar
Copy link

Hi In my case search is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment