I have a laravel page, i am sending mobile number from my javascript in my view to validate it. I have routed it properly still I am getting this error. I am posting my code snippets below, please check and help me if any errors.
profile.blade.php
function sendotp()
{
var countryData = $("#country_selector").countrySelect("getSelectedCountryData");
var isd = countryData.isd;
$("#isdcode").val(isd);
var isdcode = $("#isdcode").val();
var mobile=$("#telephone").val();
var email=$('#Email').val();
$.ajax({
url:'{{url("ajax/checkphone")}}',
method:'post',
data:{'mobile':mobile},
success:function(output)
{
obj = JSON.parse(data);
if(obj.status=='true')
{
alert("Number already exists.");
window.location ="{{url('profile')}}";
}
else {
$.ajax({
url:'{{url("ajax/registerotp")}}',
method:'post',
data:{'isdcode':isdcode,'phone':mobile,'reg_email':email, 'type': 'Update'},
success:function(output)
{
obj = JSON.parse(output);
if(obj.status=='1')
{
$("#modal-otp").modal({
backdrop: 'static',
keyboard: false
});
linkactivate();
}
else
{
$("#otp_msg").html('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>'+obj.sms+'</div>')
}
}
});
}
}
});
}
web.php
Route::post('ajax/checkphone', 'AjaxController@checkphone');
AjaxController.php
function checkphone($mobile_no){
$numbers = Users::all()->filter(function ($record) use ($mobile_no){
if(owndecrypt($record->mobile_no) == $mobile_no){
$data['message']="true";
}
else{
$data['message']="false";
}
});
echo json_encode($data);
}
This is the error which I get.
Thanks, help appreciated.