Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 重定向页面,但仍将数据带到Laravel上_Javascript_Php_Laravel - Fatal编程技术网

Javascript 重定向页面,但仍将数据带到Laravel上

Javascript 重定向页面,但仍将数据带到Laravel上,javascript,php,laravel,Javascript,Php,Laravel,我想从控制器重定向页面,但仍然将数据/数据带到那里(数据名为“valueOne”) 我用这个密码试过了 return redirect()->back()->with('alert','test'); 或 这是我在blade中的形式: //this data i get from other page, and keep this on this blade <input id="valueOne" name="valueOne" type="hidden" value="{

我想从控制器重定向页面,但仍然将数据/数据带到那里(数据名为“valueOne”)

我用这个密码试过了

return redirect()->back()->with('alert','test');

这是我在blade中的形式:

//this data i get from other page, and keep this on this blade
<input id="valueOne" name="valueOne" type="hidden" value="{{ $result->valueOne }}">


    <form action="{{URL::to('/getHalaman')}}" method="post" id="form1">
    <div class="numberOne">Number One : 
      <select id="numberOne" name="numberOne">
        <option value="null" id="numberOne">-- choose --</option>
        <option value="a">a</option>
        <option value="b">b</option>
        <option value="c">c</option>
      </select>
      </div>

      <br>

      <div class="numberTwo" style="text-align: center;">Number Two : 
      <select id="numberTwo" name="numberTwo" style="width: 200px;">
        <option value="null">-- choose --</option>
        <option value="aa">aa</option>
        <option value="bb">bb</option>
      </select>
      </div>

      <br>
      <div class="button" style="text-align: center;">
      <input id="id" name="id" type="hidden" value="{{ $result->id }}">
      <script src="js/testButton.js" type="text/javascript"></script>
      <button id="buttonSubmit" type="submit" value="Submit"> Konfirmasi </button>
    </div>
      {{ csrf_field() }}
     </div>
     </form>
这是我的路线:

Route::post('/getHalaman', 'userController@getHalaman');
我尝试了一下,却发现了像valueOne这样的错误

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
我的预期是,若用户并没有选择选项numberTwo,将在该页面上重定向,但仍然会带来valueOne


有人能帮我吗?非常感谢您在使用
及其存储在flash会话数据中的
发送数据时帮助我。

,这意味着您需要从会话中获取此数据。关于这一点,请参阅laravel文档

因此,从视图中的会话获取数据的步骤如下所示

@if(Session::has('alert'))
<div class="alert">{{ Session::get('alert')}}</div>
@endif
@if(Session::has('alert'))
{{Session::get('alert')}
@恩迪夫

首先,我们检查会话是否有警报,以防您在使用
及其存储在flash会话数据中的
发送数据时未发送,这意味着您需要从会话中获取此数据。关于这一点,请参阅laravel文档

  <div class="numberTwo" style="text-align: center;">Number Two : 
  <select id="numberTwo" name="numberTwo" style="width: 200px;">
    <option value="null">-- choose --</option>
    @foreach ($titles as $key => $val)
    @if(Session::has('alert'))
          <option value="{{ Session::get('alert')}}" selected>{{ Session::get('alert')}}</option>
    @else
          <option value="{{ $key }}">{{ $val }}</option>
    @endif      
    @endforeach
  </select>
  </div>
因此,从视图中的会话获取数据的步骤如下所示

@if(Session::has('alert'))
<div class="alert">{{ Session::get('alert')}}</div>
@endif
@if(Session::has('alert'))
{{Session::get('alert')}
@恩迪夫
首先,我们检查会话是否有警报,以防您不发送第二个:
  <div class="numberTwo" style="text-align: center;">Number Two : 
  <select id="numberTwo" name="numberTwo" style="width: 200px;">
    <option value="null">-- choose --</option>
    @foreach ($titles as $key => $val)
    @if(Session::has('alert'))
          <option value="{{ Session::get('alert')}}" selected>{{ Session::get('alert')}}</option>
    @else
          <option value="{{ $key }}">{{ $val }}</option>
    @endif      
    @endforeach
  </select>
  </div>
--选择-- @foreach($key=>$val) @if(会话::has('alert')) {{Session::get('alert')} @否则 {{$val} @恩迪夫 @endforeach
第二条:
--选择--
@foreach($key=>$val)
@if(会话::has('alert'))
{{Session::get('alert')}
@否则
{{$val}
@恩迪夫
@endforeach
试试这个

第一次自动卸载

composer dump-autoload
在你看来,

@if(Session::has('message'))
     <p class="alert {{ Session::get('alert-class', 'alert-info') }}">{{ Session::get('message') }}</p>
@endif
@if(会话::has('message'))

{{Session::get('message')}

@恩迪夫
希望这有帮助:)

试试这个

第一次自动卸载

composer dump-autoload
在你看来,

@if(Session::has('message'))
     <p class="alert {{ Session::get('alert-class', 'alert-info') }}">{{ Session::get('message') }}</p>
@endif
@if(会话::has('message'))

{{Session::get('message')}

@恩迪夫

希望这有帮助:)

返回重定向()->back()->带有('alert','test')
它在flash会话中的存储,要获得它,您需要像
Session::get('alert')@KaranSadana我必须把它放在哪里?对不起,我是新来的laravel@KaranSadana先生,你能给我举个例子吗?在我的回答中看到$result是从哪里来的吗?它是否存储在会话中@YeruAdi
return redirect()->back()->带有('alert','test')
它在flash会话中的存储,要获得它,您需要像
Session::get('alert')@KaranSadana我必须把它放在哪里?对不起,我是新来的laravel@KaranSadana先生,你能给我举个例子吗?在我的回答中看到$result是从哪里来的吗?它是否存储在会话中@Yeruadi您还有另一个选项可以使用return redirect()->back()->withInput()->with('alert','test')返回输入;您还有另一个选项可以使用return redirect()->back()->withInput()->with('alert','test')返回输入;用name检查您传递的名称,因此我使用带有('alert','test')的
alert
return redirect()->back()->所以我使用alert来检查你传递的名称,因此我使用
alert
return redirect()->back()->with('alert','test')所以我使用警报获取