tomassbo, davidningthoujam liked this thread
Hello Tomas,
How are you routes defined? Do they share the same middleware? (Do they have the same session handler). Else you have a new session for the AJAX request then for your normal page.
And you should return the data and not echo it. (Laravel will transform an array to json or you can create a new JsonResponse. So:
public function MyFunction(Request $request){
$return = [];
$return["success"] = true;
$return["msg"] = "";
//I run more functions
session()->put('variable', $var);
$return["success"] = true;
$return["msg"] = "...";
return $return;
// or with response
return new \Illuminate\Http\JsonResponse($return);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community