繁体   English   中英

jQuery:如何使用参数和正文进行http请求?

[英]jQuery: how to make http request with arguments and body?

所以我想用正文(例如file, file2, file3 )和诸如action=delete类的参数发出一个http请求,如何用jquery发出这样的请求?

使用url传递参数,使用body传递files

$.ajax({
    url: 'someurl' + '?action=delete',
    type: 'POST',
    data: requestbodyhere,
    success: function(responseData){
    }
});

您要执行POST吗? 您可以使用Ajax做到这一点:

jQuery.ajax({
  type: 'POST',
  url: url,
  data: {
    file1:'file1',
    flie2:'file2'
  },
  success: function(response) {
    //in response you have the answer from the server as a string
  }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM