我需要传递路由参数,ajax但我在ajax代码中使用命名路由方法。
路线我想去 路线
Route::post('/edit/{id}', 'ArticleController@updateArticle')->name('updateArticle');
Run Code Online (Sandbox Code Playgroud)
阿贾克斯
var id= $("input[name=editId]").val();
$.ajax({
type:'POST',
enctype: 'multipart/form-data',
url:"{{ route('updateArticle',"id") }}",
data: formdata,
contentType: false,
processData: false,
success:function(data){
$('.alert-success').html(data.success).fadeIn('slow');
$('.alert-success').delay(3000).fadeOut('slow');
}
});
Run Code Online (Sandbox Code Playgroud)
我想id在ajaxURL 中使用变量。