1

laravel Controller

if($validator->failed())
{
    return redirect()->back()->with(['errors'=>$validator->errors(),'input'=>$request]);
}

JavaScript file

<script  type="text/javascript" >
    var registrationErrors = @json($errors);
    var input= @json($input);
</script>

In this case registrationErrors it's working fine but input return error like

Action Facade\Ignition\Http\Controllers\ExecuteSolutionController not defined.

4
  • So only @json($input) is not working? Commented Jul 27, 2020 at 10:21
  • No it's not working Commented Jul 28, 2020 at 9:12
  • Can you add an example of the $input object? Commented Jul 28, 2020 at 10:16
  • $input data is a $request->all(); object Commented Jul 28, 2020 at 14:01

1 Answer 1

1

If pass only one argument in with() function that should be work fine. Laravel Controller

if($validator->failed())
{
     $data=["errors"=>$validator->errors(),
            "input" => $input 
           ];
     return redirect()->back()->with('data',$data);
}

Java Script

<script  type="text/javascript" >
     var data = @json($data);
</script>

My issue is solved, this way is perfectly working

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.