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

176
Views
get value from an input using javascript and laravel

i need to get the value of the input with javascript.

Input:

<input id="user_id" value="5" name="user_id" type="hidden">

Controller:

 public function savetoken(Request $request)
{


    
    $this->validate($request, [
        'user_id'     =>  'required',
        'token'  =>  'required',
       ]);

        Notificaciones::create([
          'user_id'  => $request->user_id,
          'token' => $request->token
        ]);
  
        return back()->with('success', 'token saved successfully!');
}

How to get the Value of the Input that is Hidden? Javascript:

 function guardarToken(token){
    var formData=new FormData();
    formData.append('token',token);
    formData.append('user_id', user_id);

    var config = {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"').content

        } 
    }

    axios.post('/token',formData, config).then( respuesta=>{
        console.log(respuesta);
    }).catch( e=>{
        console.log(e);
    });
}

I tried this way but I have not succeeded

help please

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