我可能遗漏了一些东西,但我无法理解发生了什么。
我的 php 脚本中的$_POST
变量值与表单数据中发送的值不匹配。
这就是我正在做的事情。我正在向同一个 php 脚本发送两个连续的请求。除了一个字段外,两个请求中的所有表单数据值都相同。然而,在 php 脚本中,$_POST
变量在两个请求中的该字段具有相同的值。
这是我在第一个请求中向服务器发送的原始表单数据:
sEcho=1&iColumns=1&sColumns=&iDisplayStart=0&iDisplayLength=20&mDataProp_0=0&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&fromSid=1050&fromTable=file2.xlsx&toSid=1049&toTable=file1.xlsx&fromTransInput=columnToMatch&toTransInput=columnToMatch&toTransInput = columnTable
这是我在 php 脚本中得到的原始输入内容:
sEcho=1&iColumns=1&sColumns=&iDisplayStart=0&iDisplayLength=20&mDataProp_0=0&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&fromSid=1050&fromTable=file2.xlsx&toSid=1049&toTable=file1.xlsx&fromTransInput=columnToMatch&toTransInput=columnToMatch&toTransInput=columnToMatch&0= "getDistinctTolumTable =columnToMatch &0="
请注意,操作值不匹配。而我在 php 脚本中的值实际上是在第二个请求中发送的操作值。
这是第二个请求表单数据:
sEcho=1&iColumns=1&sColumns=&iDisplayStart=0&iDisplayLength=20&mDataProp_0=0&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&fromSid=1050&fromTable=file2.xlsx&toSid=1049&toTable=file1.xlsx&fromTransInput=columnToMatch&toTransInput=columnToMatch&0=getDistinctTolumTable=columnToMatch&toTransInputTable = columnToMatch
这是来自 php 脚本的第二个请求的原始输入内容:
sEcho=1&iColumns=1&sColumns=&iDisplayStart=0&iDisplayLength=20&mDataProp_0=0&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&fromSid=1050&fromTable=file2.xlsx&toSid=1049&toTable=file1.xlsx&fromTransInput=columnToMatch&toTransInput=columnToMatch&0=getDistinctTolumTable=columnToMatch&toTransInputTable = columnToMatch
有什么想法吗?
更新:这是一些代码:
在客户端我有这个:
对于第一个请求:
$.ajax({ url: '../dataMatchChecker/getDataTables.php', 数据: [{"name":"sEcho","value":1},{"name":"iColumns","value": 1},{"name":"sColumns","value":""},{"name":"iDisplayStart","value":0},{"name":"iDisplayLength","value":20 },{"name":"mDataProp_0","value":0},{"name":"sSearch","value":""},{"name":"bRegex","value":false} ,{"name":"sSearch_0","value":""},{"name":"bRegex_0","value":false},{"name":"bSearchable_0","value":true}, {“姓名”:"fromSid","value":"1050"},{"name":"fromTable","value":"file2.xlsx"},{"name":"toSid","value":"1049"} ,{"name":"toTable","value":"file1.xlsx"},{"name":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value ":"columnToMatch"},{"name":"action","value":" getDistinctFromTablename":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value":"columnToMatch"},{"name":"action","value":" getDistinctFromTablename":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value":"columnToMatch"},{"name":"action","value":" getDistinctFromTable"},{"name":"pageLength","value":20}], type: 'post', dataType: 'json', success: function(json) { // 在这里做一些工作 } });
对于第二个请求:
$.ajax({ url: '../dataMatchChecker/getDataTables.php', 数据: [{"name":"sEcho","value":1},{"name":"iColumns","value": 1},{"name":"sColumns","value":""},{"name":"iDisplayStart","value":0},{"name":"iDisplayLength","value":20 },{"name":"mDataProp_0","value":0},{"name":"sSearch","value":""},{"name":"bRegex","value":false} ,{"name":"sSearch_0","value":""},{"name":"bRegex_0","value":false},{"name":"bSearchable_0","value":true}, {“姓名”:"fromSid","value":"1050"},{"name":"fromTable","value":"file2.xlsx"},{"name":"toSid","value":"1049"} ,{"name":"toTable","value":"file1.xlsx"},{"name":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value ":"columnToMatch"},{"name":"action","value":" getDistinctToTablename":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value":"columnToMatch"},{"name":"action","value":" getDistinctToTablename":"fromTransInput","value":"columnToMatch"},{"name":"toTransInput","value":"columnToMatch"},{"name":"action","value":" getDistinctToTable"},{"name":"pageLength","value":20}], type: 'post', dataType: 'json', success: function(json) { // 在这里做一些工作 } });
现在在我的服务器上,我只是 var_dump$_POST
变量(我还 var_dump 上面介绍的原始内容):
var_dump($_POST);
$postdata = file_get_contents("php://input");
var_dump($postdata);