Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Laravel Dynamic Ajax Dependent Dropdown

I Dont know whats wrong with this code but when i choose one of it no option value shown

Here my Blade View

<div style="overflow:hidden; float:left; width:250px;">
   <select id="division" class="" name="">
          <option value="groups">-- Division --</option>
          <option value="Male">Male</option>
          <option value="Female">Femmaleale</option>
    </select><br>
    <select id="participant">
          <option value="choosetools">-- Choose Participant --</option>
    </select>
</div>

here my script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <script>
  $(document).ready(function(){
    $('#division').change(function(){
       var division = $('#division').val();
       $('#participant').html('');
        $.ajax({
          url:'getParticipant/{id}',
          type:'GET',
          data:{myID:division},
          dataType: "json",
          success:function(data)
          {

            $.each(data, function(key, participant)
             {
              // alert(city.city_name)
              $('#participant').prop('disabled', false).css('background','aliceblue').append('<option value="'+participant.gymnastid+'">'+'participant.FULLNAME'+'</option>');
            });
          }
      });
    });
  });
  </script>

here my route

Route::get('/getParticipant/', 'App\Http\Controllers\ScoreController@getParticipant');

here my controller

public function getParticipant()
{
      $getdiv = $_GET['divSelect'];

      if ($getdiv == 'Male') {
        $res = Magmodel::all();
        return Response::json($res);
      }else{
        $res = Wagmodel::all();
        return Response::json($res);
      }
}

Can Someone please help me so all data from model Magmodel or Wagmodel showup based on dropdown choose

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!