conflict of routes?

0

I am making an ajax request: Ajax petition.

    function ver_detalles_team() {
  $(".card").hover(function () {
    let team_id = parseInt($(this).find("span:first-child").html());
    var carta = this;
    console.log("entro al evento hover")
    setTimeout(function () {
      $.ajax({
        method: "POST",
        url: "team/" + team_id,
        dataType: "html",
        timeout: 2000,
        error: function (error) {
          console.log(error);
        },
        success: function (res) {
          $(carta).append(res);
        }

      })
    }, 4000)

  })
}

and the route configured so that my controller can process it:

post 'team/:team_id',to:"teams#detalle_team"

when the "hover" event is executed, it sends the ajax request, but with the url changed to what I am sending, since I get an error in the rails console:

What is due. Thank you

    
asked by 11.09.2017 в 17:24
source

1 answer

0

When using url: "team/" you are establishing a relative route , that is, your current route is going to add team/:id ; what you are looking for is an absolute route, which you can achieve by adding / at the beginning, like this:

url: "/team/" + team_id,
    
answered by 11.09.2017 / 17:37
source