1

I try to put an ID value behind a radio checked element for each record. It works fine on VIEW side, but now I want to get this ID VIA JQuery selector and POST it on ajax. My HTML looks as following:

<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>

This is my 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(),

Note that url site is my contorller file and getInternalTicketPrice is my function that has only this:

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

On console I get:

string(15) "[object Object]"

Any idea how to return the actual value of route_value ="'.$data['route'][$i]['id'].'"? Thank you!

Miril Terolli
  • 211
  • 1
  • 5
  • 14

1 Answers1

1

Solved! Just modified the selector like this :

$("input[name='cursa_radio']:checked").attr("route_value")
Miril Terolli
  • 211
  • 1
  • 5
  • 14