单击表格行并使用jquery和laravel 5重定向到视图

时间:2015-09-21 10:52:52

标签: laravel-5.1

有一个表格可以呈现一些具有以下列的人员列表:

<table>
    <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Age</th>
    </tr>
    <tr class="person">
        <td class="fname">John</td>
        <td class="lname">Doe</td>
        <td class="age">30</td>
    </tr>
</table>

等等。当用户单击某行时,应使用jquery加载包含有关所选preson的更多数据的新视图。类似的东西:

// main.js:

$(document).ready(function(){
    $("#person").click(function(){
        var lname = $(this).children("lname").val();
        $.ajax({
            url:'profile',
            type: 'GET',
            data: 'lname' : lname,
            dataType: 'json',
            success: function(result){

            }
        });
    }
});

// routes.php文件:

Route::get('profile', [
    'as' => 'profile',
    'uses' => 'PagesController@profile'
]);

// Controller.php这样

public function profile()
{
    return view('pages.profile');
}

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

private void button1_Click(object sender, EventArgs e)
    {
        label1.Text = textBox1.Text;

        Form2 frm = new Form2();
        frm.Show();
        this.Hide();
    }

将有助于希望