imamhsn195
4 months ago

Function is not defined showing in console but Function is exists in file

Posted 4 months ago by imamhsn195

This is a laravel Project.

Here the routes:

Route::get('customers/{phone}','[email protected]');
Route::resource('customers','CustomerController');
``` public function index($phone = null)
    {
        $customers = Customer::orderBy('id', 'DESC')->get();
        if($phone !== null){
            return  $customers = Customer::with('vehicles','user')->whereHas('user',function($query)use($phone){
                $query->where('phone',$phone);
            })->first();
        }
        return view('customers.index',compact('customers'));
    }

Here is the blade file

<input type="text" onchange="FindPartyInfo(this.value)" class="form-control {{$errors->has('phone')?'border-danger':''}}" name="phone" placeholder="018XXXXXXXX"/>
@if ($errors->has('phone'))
    <span class="text-danger">{{$errors->first('phone')}}</span>
@endif

// Find Existing party information
        function FindPartyInfo(phone){
            $("#vehicle_id").empty();
            $("#vehicle_id").append("<option value='new'>New Vehicle</option>");
            var route ="http://localhost/auto_shop/public/customers/"+phone;
            $.get(route, function(data) {
                $("input[name=name]").val(data.name);
                $("input[name=address]").val(data.address);  
                var vehicleList = "<option value='new'>New Vehicle</option>";
                if(data.vehicles.length>0){
                    for(i=0;i<data.vehicles.length;i++){
                        vehicleList += "<option value='"+data.vehicles[i].id+"'>"+data.vehicles[i].vehicle_name+" | "+data.vehicles[i].vehicle_no+" | "+data.vehicles[i].vehicle_cc+"</option>"; 
                    }
                    $("#vehicle_id").empty();
                    $("#vehicle_id_hidden").empty();
                    $("#vehicle_id").append(vehicleList);  
                }
            });
        }

Console :

ReferenceError: FindPartyInfo is not definedorders:1:1
    onchange http://127.0.0.1:8000/orders:1

Please sign in or create an account to participate in this conversation.