In consloe I am getting correct data
The console output is ...
Response:
{"success":true,"info":[{"id":7,"imei_number":2147483647,"device_name":"reeeeeeeee","email_id":"test
@gmail.com","created_at":"2016-05-23 05:52:39","updated_at":"2016-05-23 05:52:39"}]}
but i am not getting in view page
Than you must return view in your controller
return (String) view('some_view');
@tom_pongrac
In controller i am already returning response know .
Controller:
public function getInfo($id)
{
$fill = DB::table('register_devices')->where('imei_number', $id)->get();
return Response::json(['success'=>true, 'info'=>$fill]);
}
Then in ajax success i have to get response know.But i am not getting values in ajax success.
In my view only i wrote ajax.
Can you only return
return Response::json($fill);
and then in ajax try
data. imei_number
I tried .. but i am getting as undefined...
then try
console.log(data);
console.log(data) output:
[Object { id=7, imei_number=2147483647, device_name="reeeeeeeee", more...}]
try this in jquery
$.ajax({
url: '/infos/' + selected_imei,
type: 'get',
data: {},
success: function(data) {
var obj = $.parseJSON(data);
alert(obj[0].imei_number);
}
});
or if dont work write
console.log(data)
@tomo_pongrac
Thank you very much tomo.. U r awesome u r nice support and guidelines
I got the sollution..
Full solllution:
tom_pongrac's post:
Url should be : url: '/laravel/GpsTrack/public/getInfo/' + selected_imei,
and
json string has an array format. I need to access the json object properties like this
$.ajax({
url: '/laravel/GpsTrack/public/getInfo/' + selected_imei,
type: 'get',
dataType: 'JSON',
data: {},
success: function(data) {
// $("iname").value = data.info.imei_number;
alert("...."+data.info[0].imei_number);
}
});
once again thank u to @Reached @clay @tomo_pongrac @petrit
Please or to participate in this conversation.