get请求只能传query参数,query参数是通过拼在url上。比如:

https://www.baidu.com?a=1&b=2

post请求可以传body和query两种形式的参数:

body传参:
$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxx",
   data : {
    ids: tempID
    }
   ...
  })
body传参,当要求传JSON格式的参数时:
$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxxxx",
   dataType : "json",
   data : JSON.stringify({ids: tempID}),
   contentType:"application/json;charset=utf-8",
    ...
  })

当query传参时:

$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxx",
   params: params // params就是query参数,params的值只能是一个字符串,不能传递对象类型的参数,如                     
                  // 果参数中涉及到了传递对象,就要选择body传参。
   ...
  })

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐