Laravel Form Submit接收未定义的


Laravel Form Submit receives undefined

编辑: 我刚刚发现,这个错误是从我的jquery.mobile-1.2.min.js中生成的。我不知道为什么,也不知道如何解决,但我想,我只是应该让你们知道

出于某种原因,我无法提交。请帮忙。

这些是我的路线:

    Route::get('forms/{unit_id}/{qr_id}', 'FormController@index');
Route::resource('units.qr.score', 'ScoreController');

这些是我的控制器:

FormController:

public function index($unit_id, $qr_id)
{
    //
    return View::make('form.index')
        ->with('unit_id', $unit_id)
        ->with('qr_id', $qr_id);
}

ScoreController:

public function index()
{
    //
    return '<h1>Yeeeeeas?!</h1>';
}

    **// EDIT: Changed show to store**
public function store($unit_id, $qr_id)
{
    //
    return $unit_id;
}

这是我的观点:

    <!DOCTYPE html> 
<html> 
<head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.2/jquery.mobile-1.1.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.2/jquery.mobile-1.1.2.min.js"></script>
</head> 
<body> 
<div data-role="page">
    <div data-role="header">
        <h1>Title rockt</h1>
    </div><!-- /header -->
    <div data-role="content">   
        <p>Hello world</p>  
        {{Form::open(array('route' => array('units.qr.score.store', $unit_id, $qr_id)))}}
            {{Form::label('rating1')}}
            {{Form::input('range', 'rating1', 50, array('min' => '0', 'max' => '100', 'data-highlight' => 'true', 'id' => 'rating1', 'placeholder' => 'What the fuck?'))}}
            {{Form::label('Test1')}}
            {{Form::text('Test1')}}
            {{Form::submit('Submit')}}
        {{Form::close()}}   
    </div><!-- /content -->
</div><!-- /page -->
</body>
</html>

所以,我不知道为什么当我按下提交按钮时,我只收到一条消息"未定义"。如果我重新加载,它会从我的ScoreController返回正确的值。

这是一张屏幕截图:https://i.stack.imgur.com/E6KIH.png

我们将不胜感激。

谢谢,爱,

George

jQuery Mobile出现问题

您需要返回一个完整的jQuery Mobile页面。

相关问题:

  • JQuery Mobile-changePage结果:未定义
  • 为什么我看到当我在jQuery中提交表单时,屏幕上的"未定义"值移动

Store不应该有参数。使用输入::get('unit_id','unit-id-empty'(;它已张贴。

编辑:并将单元id等作为隐藏输入。。

根据decker正确写入的内容,解决方案是在每个链接和提交按钮中插入以下参数:

 data-ajax="false"

像这样:

 {{Form::open(array('url' => 'whatever', 'method' => 'POST', 'data-ajax' => 'false'))}}

或者像这样:

 {{link_to('whatever', 'whatever', array('data-ajax' => 'false'))}}

这里的另一个资源:

jQuery Mobile链接在没有数据的情况下无法工作ajax=";"假";,为什么?