Php 在CI上使用post方法通过ajax在href上发送值
我对ajax有问题。当我无法使用href属性上的post方法在ajax上发送值时。。 这是我的源代码Php 在CI上使用post方法通过ajax在href上发送值,php,ajax,codeigniter,Php,Ajax,Codeigniter,我对ajax有问题。当我无法使用href属性上的post方法在ajax上发送值时。。 这是我的源代码 function show_TIM(){ var img = "<img src='"+site_url+"public/images/load.gif' align='center'>"; $("#TIM").html(img); event.preventDefault(); $.ajax({ type:"post",
function show_TIM(){
var img = "<img src='"+site_url+"public/images/load.gif' align='center'>";
$("#TIM").html(img);
event.preventDefault();
$.ajax({
type:"post",
url: site_url+'index.php/controller/function/#needvaluerighthere',
data: {
link : $(this).attr('href'),
},
success:function(msg){
$('#TIM').html(msg);
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
'iDisplayLength': 100
});
}
});
}
函数show_TIM(){
var img=“”;
$(“#TIM”).html(img);
event.preventDefault();
$.ajax({
类型:“post”,
url:site_url+'index.php/controller/function/#needvaluerightshere',
数据:{
链接:$(this.attr('href'),
},
成功:功能(msg){
$('#TIM').html(msg);
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”,
“iDisplayLength”:100
});
}
});
}
hmtl代码是
<a href="'.$row['TIM_KE'].'" class="link" style="text-decoration: none;" data-toggle="modal" data-target=".TIM" data-artid="'.$row['TIM_KE'].'" onclick="show_TIM();">
我尝试用ajax捕获$row['TIM_KE'],并将值发送给控制器。。。
不管怎样,我用密码器。。。
请帮助我。您将有一个添加单击事件侦听器,此函数中没有引用 事件呼叫
$(document).on('click', 'a', function() {
show_TIM($(this).attr('href'));
});
AJAX调用
function show_TIM(value){
var img = "<img src='"+site_url+"public/images/load.gif' align='center'>";
$("#TIM").html(img);
event.preventDefault();
$.ajax({
type:"post",
url: site_url+'index.php/controller/function/#needvaluerighthere',
data: {
link : value,
},
success:function(msg){
$('#TIM').html(msg);
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
'iDisplayLength': 100
});
}
});
}
功能显示时间(值){
var img=“”;
$(“#TIM”).html(img);
event.preventDefault();
$.ajax({
类型:“post”,
url:site_url+'index.php/controller/function/#needvaluerightshere',
数据:{
链接:价值,
},
成功:功能(msg){
$('#TIM').html(msg);
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”,
“iDisplayLength”:100
});
}
});
}