我有问题白衣ajax。当我无法使用href属性上的post方法在ajax上发送值时.. 这个ajax我的源代码......
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
});
}
});
}
,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']并将值发送到控制器... 无论如何,我使用CodiIgniter ... 请帮帮我..
答案 0 :(得分:0)
您将添加一个点击事件监听器,此在该功能中没有引用
EVENT CALL
$(document).on('click', 'a', function() {
show_TIM($(this).attr('href'));
});
AJAX CALL
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
});
}
});
}