2016-11-10 56 views
1

我尝试将一个ID值放在每个记录的无线电检查元素后面。它在VIEW方面工作正常,但现在我想获得这个ID VIA JQuery选择器并将其POST在ajax上。 我的HTML看起来如下:获取与jquery选择器检查行值id

<td> 
    <input type="radio" name="cursa_radio" id="cursa_radio" value="ticket_selected" route_value ="'.$data['route'][$i]['id'].'"> 
      '.$data['route'][$i]['departure_station'].' //actual td value 
</td> 

这是我的ajax:

$.ajax({ 

    url: MyVariable.urlsite + "curse_interne/getInternalTicketPrice", 
    type: "POST", 
    dataType: 'json', 
    data: $("#first_step").serialize() 
    + '&internal_route_id=' + $("input[name='cursa_radio']:checked ").text('value') 
    + '&' + $("#first_step").serialize(), 

注意网址的网站是我的contorller文件和getInternalTicketPrice是我的函数,只有这个:

$a = $this->input->post('internal_route_id'); 

在控制台上,我得到:

string(15) "[object Object]" 

任何想法如何返回route_value ="'.$data['route'][$i]['id'].'"的实际值? 谢谢!

+1

使用'.val()'not'.text('value')'。此外,你追加序列化表格数据两次 –

+0

相同...我得到字符串(15)“[对象对象]” –

回答

1

解决! 只是像这样修改选择器:

$("input[name='cursa_radio']:checked").attr("route_value")