6 months ago

dropdown using ajax data fetch

Posted 6 months ago by Van1310

i have 2 tables

  1. job -> job,
  2. jobtitle -> city

i want to fetch citywise job in dropdown

here my blade file

<label for="exampleSelect1">City</label>
<select class="form-control m-input" id="city" name="city" onChange="getCity(this.value);">
    <option value="bhavnagar"> Bhavnagar </option>
            <option value="ahmedabad"> Ahmedabad </option>

<label for="exampleSelect1">Job Title</label>
<select class="form-control m-input" id="jobtitle" name="jobtitle" >
    @foreach($jobtitle as $job)
        <option value="{{$job->jobtitle}}"> {{$job->jobtitle}} </option>

here is my ajax code

    function getCity(val) {
        type: "POST",
        foreach($jobtitle as $job)
                url: "{{route('',['id'=>$job->id])}}",
        success: function(data){

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