我需要使用带有函数值的ajax。 我有,例如标签与“ID = 36”,我在HTML中度日的OnClick:ajax与codeigniter中的函数值
id="<?=$row['customer_id'];?>" onclick="test(this.id)">
现在我需要努力低谷吧。 我的java脚本代码:
<script type="text/javascript">
function test(clicked_id) {
var value = { 'id' : 36; };
$.ajax({
type: 'POST',
url: '<?php echo site_url('test/ret(id)'); ?>',
data: value,
success: function(resp) {
$('#data').html(resp);
}
});
}
</script>
我知道一些错误!但什么?! 身份证我得到我正确的,但我怎么能发送和使用它在Java脚本? 的VAR值没有得到“身份证”,我认为
url: '<?php echo site_url('test/ret(id)'); ?>'
实在是太不正确!我如何发送ID槽功能?
[编辑](http://stackoverflow.com/p osts/38703824 /编辑)问题并显示您的控制器代码。 – DFriend
你不需要URL中的'id'。它已经通过POST变量传递。只需在'ret()'方法的'Test.php'控制器中用'$ this-> input-> post('id')'来获取它。 – Tpojka