Getting a 405 method not allowed exception

前端 未结 1 448
自闭症患者
自闭症患者 2021-01-21 04:06

I have a jquery script(downloaded from github) that deletes the entities. Following is the script.

$(document).ready(function() {


var restful = {

    init: f         


        
相关标签:
1条回答
  • 2021-01-21 04:17

    You have used method:DELETE instead use following in your ajax call

    $.ajax({
        headers: {...},
        url: self.attr('href'),
        type:"post",
        data: { _method:"DELETE" },
        success: function(data) {...},
        error: function(data) {...}
    });
    

    Laravel will look for the _method in POST and then the DELETE request will be used if found the method.

    Update: (Because of this answer, pointed by nietonfir)

    You may try DELETE method directly like this (if it doesn't work then try the other one), :

    $.ajax({
        headers: {...},
        url: self.attr('href'),
        type:"DELETE",
        success: function(data) {...},
        error: function(data) {...}
    });
    
    0 讨论(0)
提交回复
热议问题