[英]Laravel : how to pass variable from one function to other coming from ajax call in same controller
I am new to laravel facing issue to pass variable from one function to another function i want to pass getidvalue variable from questionquiz5 to previousbtn function?? 我是laravel的新手,面临将变量从一个函数传递到另一个函数的问题,我想将getidvalue变量从questionquiz5传递给previousbtn函数? here is my code 这是我的代码
public function questionquiz5(Request $request){
static $startscore=0;
static $getscore;
static $level;
$var = "hi";
$getidvalue = Input::get('getid');
$getanswervalue = Input::get('getanswer');
$dbscore = \DB::table('5question')->select('question_id','correct_answer','question_marks','question_level')->where('question_id','=',$getidvalue)->get();
//// some code...........
Session::push('getscoresession',$getscore);
Session::push('level',$level);
$getsession = [ 'qid' => $getidvalue, 'answer' => $getanswervalue];
Session::push('answer', $getsession);
return response()->json(['qid'=>$getidvalue,'answer'=>$getanswervalue]);
return $this->previousbtn( $getidvalue);
return $this->previousbtn( $getanswervalue);
}
**previousbtn function:**
public function previousbtn(Request $request, $getidvalue)
{
$prevbtnvalue = Input::get('page');
$getcompid = $this->getidvalue;
echo "$getcompid";
}
the error: 错误:
getting error : Type error: Too few arguments to function App\\Http\\Controllers\\scorecontroller::previousbtn(), 1 passed and exactly 2 expected 出现错误:类型错误:函数App \\ Http \\ Controllers \\ scorecontroller :: previousbtn()的参数太少,已传递1个,正好是2个
Like the error indicates, you are passing too few arugments. 像错误所指示的那样,您传递的麻将太少。
return $this->previousbtn( $getidvalue);
Should be 应该
return $this->previousbtn($request, $getidvalue);
Or if the request object is not used in the previousbtn
method you can remove it from the arguments. 或者,如果previousbtn
方法未使用请求对象,则可以将其从参数中删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.