![](/img/trans.png)
[英]jQuery Ajax PHP POST method with response array[] instad sent data. How to get send values in response?
[英]How to preserve NULL values in jQuery ajax POST sent to PHP script?
假设我有一个PlainObject:
formData: completed: null limit: "10"
然后在ajax调用中使用它:
$.ajax({
type: 'post',
url: SomeEndpoint.php,
data: formData,
}).done(function (response) { do stuff }
SomeEndpoint.php中的POST值将所有值接收为空字符串:
$completed = $_POST['completed'] ?? null; // ""
$limit = $_POST['limit'] ?? null; // "10"
如何保存打字? 如果端点验证变量是NULL还是Int / Bool,验证类型的最佳方法是什么?
您可以使用jquery验证作为验证器-https: //jqueryvalidation.org/
选项-https: //jqueryvalidation.org/category/plugin/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.