简体   繁体   English

如何在jQuery AJAX调用中发送所有当前发布数据

[英]How to send all current post data in jQuery AJAX call

So I'm working on a site and I am setting up a register system, and I want the site to take all of the current POST data (after the request was made) and send the current POST data in an AJAX call, like: 所以我在一个网站上工作,正在建立一个注册系统,我希望该网站接收所有当前的POST数据(after the request was made)并通过AJAX调用发送当前的POST数据,例如:

$.post('/api/post', {
  "type":"register",
  "pdata":POST_DATA
}, function(data){
  alert(data);
});

And have the PHP Backend be able to take in the $_POST['pdata'] and use that as the data it's going to use, just to make the transfer safer and easier. 并且让PHP Backend能够接受$_POST['pdata']并将其用作将要使用的数据,只是为了使传输更安全,更容易。

Try use serialize() 尝试使用serialize()

You can send all your form data 您可以发送所有表格数据

$.post('/api/post', {
  "type":"register",
  "pdata":$('.your_form_class_name').serialize()
}, function(data){
  alert(data);
});

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

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