如何用jQuery AJAX调用发送所有当前的post数据
16lz
2021-01-22
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数据(请求发出后),然后用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后端能够接收$_POST['pdata'],并将其用作将要使用的数据,以使传输更安全、更容易。
1 个解决方案
#1
2
Try use serialize()
尝试使用序列化()
You can send all your form data
您可以发送所有的表单数据
$.post('/api/post', {
"type":"register",
"pdata":$('.your_form_class_name').serialize()
}, function(data){
alert(data);
});
更多相关文章
- 解决PHP导出大量数据时设置超链接的问题
- 如何在mysql中配置区分大小写的数据库标识符
- 根据网址上的国家/地区将用户重定向到正确的数据库,我使用i18n fo
- 获取所有网站的错误,[重复]
- ThinkPHP连接主从数据库
- 使用AJAX将数据发送到.php文件,如何从中获取数据?
- 什么是从我的PHP网站过滤无效的utf8?
- php把从数据库读取出来的数据存放到数组里
- 迭代文件夹中的CSV文件,并使用PHP将数据加载到MySQL中