2016-05-13 70 views
4

所以在我的Laravel项目中,我有路线福尔请求,这看起来像古典为GET格式的请求路由

Route::get('edit/{user}', '[email protected]'); 
Route::post('delete', '[email protected]'); 

等 的问题是,我不知道如何通过GET请求链接传递变量。例如,当我通过一些变量与我联系,像

$.get("{{action('Admin\[email protected]')}}", {user: id}) 

我得到的链接,看起来像

/编辑?USER = 123

而且这种格式不匹配有一个写在roures.php中,其中只提到了斜线。我应该怎么做才能正常工作?不知何故,让请求看起来像/编辑/ 123或重写路由中的东西?

P.S我知道我可以简单地使用$.get('/edit/'+id),但我强烈需要它是{{action}}

+2

你见过这样的职位? http://stackoverflow.com/questions/27298426/how-to-pass-get-parameters-to-laravel-from-with-get-method –

+0

@ReeceCottam现在我有,谢谢你,我会尽量让一些东西出来这个的! – Coffee

+0

没问题,乐意帮忙=] –

回答

3

作为您的路线,您应该发送id与URL不作为数据saperately。它会像

url : "/edit/id", 

或作出Route::get('edit', '[email protected]'); 路线和编辑ID的行等于$request->id;