Hello, I’m doing an ajax call to fill a form using an “ID”
Ajax Call
$(document).ready(function () {
$("#searchbtn").click( function() {
var ncmrid = $('#search').val();
$.ajax({
url: "http://localhost/ncmr/index.php/ncmr/get_ncmr_by_id",
async: false,
type: "POST",
data: "idncmr="+ncmrid,
dataType: "html",
success: function(data) {
$('#form').html(data);
}
})
});
});
HTML VIEW
<input type="text" class="form-control" placeholder="Search by NCMR ID" id="search" />
<button class="btn btn-default" type="button" id="searchbtn">Search</button>
<div id="form">
</div>
CONTROLLER
Basically my controller get information from a table using the ID
$id = $this->input->post('idncmr');
$data['ncmr'] = $this->ncmr_model->get_ncmr_by_id($id);
print_r($data['ncmr']);
The result is loaded on the DIV as
Array ( [0] => stdClass Object ( [ID] => 1 [Plant] => 3 [Id_ncmr] => 4781 [Description] => SCRAP [Submitby] => xxx [Submit_date] => 2011-02-09 [Promise_date] => 2011-02-16 [Close_date] => 0000-00-00 [Program] => 532 [Partnum] => 218 [Found_in] => 4 [Status] => 1 ) )
I would like to put the ID, Plant,etc values on an Input text
I know how to put all the array on an input text with
success: function(data) {
$('#id_input').val(data);
}
But I would like to put individual values on different input texts, anyone know how to access to the individual values on this example?
thank you.