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

144
Views
trying to insert multi select input with ajax

I am trying to store multi-select input with ajax in Laravel but I am getting this error

{message: "Function name must be a string", exception: "Error", …}

here is my blade code

<select class="" multiple="" id="medicine_pills" name="medicine_pills[]">
    <option value="2">test</option>
    <option value="2">test</option>
</select>

var medicine_pills = $('#medicine_pills').val();
$.ajax({
    url: '{{ url('medicine') }}',
    type: "post",
    data: {
        '_token': "{{ csrf_token() }}",
        'medicine_pills': medicine_pills,
        'last_appointment_id': last_appointment_id,
    },

in controller

$medicines = request()->post('medicine_pills');

foreach ($medicines as $iteam) {
    echo $medicines;
    $user = Medicine::create([
        'medicines_cats' => $iteam,
        'appointmen_id' => $last_appointment_id,
    ]);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<select class="" multiple="" id="medicine_pills" name="medicine_pills[]">
    <option value="2">test</option>
    <option value="2">test</option>
</select>

var medicine_pills = $("input[name='medicine_pills[]']").val();
$.ajax({
    url: '{{ url('medicine') }}',
    type: "post",
    data: {
        '_token': "{{ csrf_token() }}",
        'medicine_pills': medicine_pills,
        'last_appointment_id': last_appointment_id,
    },

Please try with this.

about 4 years ago · Juan Pablo Isaza Report
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!