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

113
Views
cómo hacer que la opción de selección de ajax se pueda hacer clic y funcione

Hola, quiero mostrar datos json para seleccionar la opción a la vista, pero no se muestra y no se puede hacer clic en el campo de búsqueda

aquí está mi controlador

 public function loadNamaPengarang(Request $request) { if ($request->has('q')) { $cari = $request->q; $data = DB::table('pengarang')->select('id', 'name')->where('name', 'LIKE', '%'. $cari .'%')->get(); return response()->json($data); } }

Aquí está mi HTML

 <label class="col-sm-4 col-form-label" style="color: #452d3a;">Nama</label> <div class="col-sm-4"> <select style="width:100%;" class="form-control carinamapengarang" id="namapengarang" name="search"> </select> </div>

Y este es mi javascript

 $('.carinamapengarang').select2({ tags: true, placeholder: 'Cari...', ajax: { url: "{{url('carinamapengarang')}}", dataType: 'json', delay: 250, processResults: function (data) { return { results: $.map(data, function (item) { return { text: item.name, id: item.id } }) }; }, cache: true } });
about 4 years ago · Santiago Gelvez
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!