JQuery, send JSON object using GET method

前端 未结 4 1929
梦如初夏
梦如初夏 2020-12-14 15:41

I am trying to send a json object using GET method. My code:

$.ajax({
           url: \"/api/endpoint\",
           type: \"GET\",
           data: {\"sort\"         


        
4条回答
  •  渐次进展
    2020-12-14 16:10

    GET requests (at least usually) do not have a message body. As mentioned in the docs, jQuery appends data of GET requests to the url parameters. You should be able to read your sort parameter from there with your server application.

    BTW, no user agent will allow you to set the Content-Length header - it will (and must) be done automatically depending on the sent data.

提交回复
热议问题