JQuery, send JSON object using GET method

前端 未结 4 1925
梦如初夏
梦如初夏 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:22

    I think you should use JSON.stringify for GET parameters in URL like this:

    $.ajax({
               url: "/api/endpoint?parameters="+JSON.stringify({"sort":"date"}),
               type: "GET",
               contentType: "application/json",
               dataType: "json",
               ...
    

提交回复
热议问题