I am trying to send a customer ID
do a quick check if the user has any violations under his name. when hard coding any customer ID I am getting the expected results back into my console, I want to show that on a small alert
box, here is my code so far:
HTML:
<strong>Customer ID:</strong>
<input class="form-control" type="text" name="custidno" id='cust' autocomplete="off" onkeypress="myFunction()" placeholder="Customer ID" value="{{ old('custidno') }}">
<input type="button" id="violationchecker" class="btn btn-info" style="background:#692563;color:white;" value="Check for Violations">
Script:
var path = "{{ url('violationcheck') }}";
var singleValues = $( "#cust" ).val();
$("#violationchecker").click(function() {
$.get(path, { custidno : singleValues }
,function(data){
alert(checked)
});
});
Controller:
public function violationcheck(Request $request)
{
$checked = DB::table('violations')
->select('severity',DB::raw('count(*) as total'))
->where("custidno",$request->custidno)
->groupBy('severity')
->get();
return response()->json($checked);
}