我为我的php应用程序使用 htaccess ,现在我想使用datatable api
从php文件获取结果,我的代码:
<script type="text/javascript" charset="ISO-8859-1">
$(document).ready(function() {
var myTable=$('#resolus').dataTable( {
"bProcessing": true,
"bServerSide": true,
//"bFilter": false,
"sAjaxSource": "http://localhost/framework/public/js/requete_admin_resolus.php",
"fnServerParams": function ( aoData ) {
aoData.push({"name":"critere","value":$("select[name='choix'] option:selected").val()});
},
"sPaginationType": "full_numbers",
"aaSorting": [[ 0, "desc" ]],
"aoColumns": [
null,
null,
null,
null,
{"bSortable": false },
null,
{"bSortable": false }
],
"fnDrawCallback": function() {
$('#resolus tbody tr td').each(function(){
$(this).css('border','1px solid black');
$(this).css('text-align','center');
}),
$("#resolus tbody tr").hover(
function () {
$(this).css("background-color","#F7951E");
$(this).css('cursor','pointer');
},
function () {
$(this).css("background-color","white");
$(this).css('cursor','auto');
}
);
$("#resolus tbody tr").click(function () {
/* CLICK SUR UN ENREGISTREMENT */ mapopup("admin_detail.php?id="+$(this).find('td:first').text()+"&solution=1")
} );
},
"fnInitComplete":function() {
$(".dataTables_filter").wrap("<div id='rechercher'></div>");
$('<div style="float:left;padding-top:7px;background-color: #F7951E;"><b>Rechercher dans:</b><select id="choix" name="choix" style="margin-left:10px;margin-right:10px;"><option name="choix" value="id">Num Incident</option><option name="choix" value="date">Date</option><option name="choix" value="nom">Nom - Prénom</option><option name="choix" value="identifiant">Identifiant</option><option name="choix" value="pb">Problème</option></select></div>').insertBefore(".dataTables_filter");
$('<div class="clear"></div>').insertAfter("#rechercher");
$('<input type="button" class="rech" value="OK" />').insertAfter(".dataTables_filter :text");
$('.rech').click(function(){
myTable.fnFilter($('.dataTables_filter :text').val());
});
$('.dataTables_filter :text')
.unbind('keypress keyup')
.bind('keypress', function(e){
if (e.keyCode != 13) return;
myTable.fnFilter($(this).val());
});
},
"oLanguage": {
"sProcessing": "Traitement en cours...",
"sLengthMenu": "Nombre de lignes par page: _MENU_",
//"sLengthMenu": "",
"sZeroRecords": "Aucun élément à afficher",
//"sInfo": "Affichage de l'�lement _START_ � _END_ sur _TOTAL_ �l�ments",
"sInfo": "",
//"sInfo": "",
//"sInfoEmpty": "Affichage de l'�lement 0 � 0 sur 0 �l�ments",
"sInfoEmpty": "",
//"sInfoFiltered": "(filtr� de _MAX_ �l�ments au total)",
"sInfoFiltered": "",
"sInfoPostFix": "",
"sSearch": "",
"sUrl": "",
"oPaginate": {
"sFirst": "<<",
"sPrevious": "< Précédent",
"sNext": "Suivant >",
"sLast": ">>"
}
}
} );
} );
</script>
</head>
<body>
<TABLE class='table table-striped table-bordered' width="100%" id="resolus">
<thead>
<TR>
<TH>Num incident</TH>
<TH>Date création</TH>
<TH>Nom Prénom</TH>
<TH>Identifiants</TH>
<TH>Télephone</TH>
<TH>Description problème</TH>
<TH>Dernier dépannage</TH>
</TR>
</thead>
<tbody>
<tr>
<td colspan="7" class="dataTables_empty">Chargement des données...</td>
</tr>
</tbody>
</TABLE>
- a result of requete_admin_resolus.php is echo json_encode( $output );
- my htaccess in public folder:(i have another htaccess file in main folder but it redirect file to htacces of public folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L,QSA]
</IfModule>
this url 无法正常工作,如果我尝试without htaccess
,即使使用此网址,绝对网址或相对网址也能正常工作。我认为这是htaccess
和json
结果的问题。对不起我的英语不好。
谢谢大家。
答案 0 :(得分:0)
主文件夹中的.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^index\.php$ - [L]
RewriteRule ^$ public/ [L]
RewriteRule ^$ public/img/upload/photos/* [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
公共文件夹中的.htaccess文件:
RewriteEngine On
RewriteCond%{REQUEST_FILENAME}! - f RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?url = $ 1 [PT,L,QSA]
没有错误。这项工作完美,但与.htaccess一起工作