gpt4 book ai didi

javascript - 将参数从 JQuery 发送到 PHP 文件

转载 作者:行者123 更新时间:2023-11-30 00:04:52 25 4
gpt4 key购买 nike

我正在使用以下 JS 从 PHP 文件中获取 JSON 数组:

<script type="text/javascript" language="javascript" >
$(document).ready(function() {
var dataTable = $('#employee-grid').DataTable( {
processing: true,
serverSide: true,

ajax: "employee-grid-data.php", // json datasource

language: {
processing: "Procesando datos...",
search: "Buscar:",
lengthMenu: "Mostrar _MENU_ doctores/as",
info: "Mostrando del doctor/a _START_ al _END_ de un total de _TOTAL_ doctores/as seleccionados" ,
infoEmpty: "Mostrando doctor/a 0 al 0 de un total de 0 doctores/as",
infoFiltered: "(filtrados de _MAX_ doctores/as)",
infoPostFix: "",
loadingRecords: "Procesando datos...",
zeroRecords: "No hay doctores/as que cumplan los criterios",
emptyTable: "Noy hay datos que cumplan los criterios",
paginate: {
first: "Primero",
previous: "Anterior",
next: "Siguiente",
last: "Ultimo"
},
aria: {
sortAscending: ": activer pour trier la colonne par ordre croissant",
sortDescending: ": activer pour trier la colonne par ordre décroissant"
}
}

} );

var colvis = new $.fn.dataTable.ColVis( dataTable, {
buttonText: '<img src="images/down.gif" >',
activate: 'mouseover',
exclude: [ 0 ]
} );
$( colvis.button() ).prependTo('th:nth-child(1)');

} );
</script>

它工作正常。现在我需要将参数发送到 PHP 文件,我尝试将其添加到脚本中,就在 ajax:url 行的下方:

type: "get", //send it through get method
data:{ajaxid:"1"},

然后将其包含在 PHP 中以捕获参数:

$var = $_GET['ajaxid'];

但我得到 $var 的 'null'。我也尝试过使用 POST 方法而不是 GET 方法,但结果相同。

最佳答案

尝试:

ajax: "employee-grid-data.php?ajaxid=1"

并检查你的$_GET['ajaxid']

关于javascript - 将参数从 JQuery 发送到 PHP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38867096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com