Created
February 19, 2016 18:22
-
-
Save walihassanjafferi/39159f218dc5f811c5b1 to your computer and use it in GitHub Desktop.
Using Ajax Solr with JQuery Datatables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi In my case search is not working.