ajax post in laravel 5 return error 500 (Internal Server Error)

后端 未结 12 996
不知归路
不知归路 2020-11-29 05:13

this is my test ajax in laravel 5 (refer below)

$(\"#try\").click(function(){
    var url = $(this).attr(\"data-link\");
    $.ajax({
        url: \"test\",
         


        
12条回答
  •  时光取名叫无心
    2020-11-29 05:42

    Short and Simple Solution

    e.preventDefault();
    var value = $('#id').val();
    var id = $('#some_id').val();
    url="{{url('office/service/requirement/rule_delete/')}}" +"/"+ id;
    console.log(url);
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $.ajax({
    /* the route pointing to the post function */
        url: url,
        type: 'DELETE',
    /* send the csrf-token and the input to the controller */
        data: {message:value},
        dataType: 'JSON',
    /* remind that 'data' is the response of the AjaxController */
        success: function (data) { 
        console.log(data)
        //$('.writeinfo').append(data.msg);
        //$('#ruleRow'+id).remove();
        }
    });
    return false;
    

提交回复
热议问题