Variables appcelerator post请求。在一个请求中多次发送一个变量。
你好!我想在一个post查询中发送变量几次(每次都有不同的值)。 在HTML格式中,它可以工作,并且看起来像:Variables appcelerator post请求。在一个请求中多次发送一个变量。,variables,post,appcelerator,Variables,Post,Appcelerator,你好!我想在一个post查询中发送变量几次(每次都有不同的值)。 在HTML格式中,它可以工作,并且看起来像: <form method="POST" action="http://localhost/index.php"> <input type="hidden" name="line_item" value="value1"> <input type="hidden" name="line_item" value="value2">
<form method="POST" action="http://localhost/index.php">
<input type="hidden" name="line_item" value="value1">
<input type="hidden" name="line_item" value="value2">
<input type="hidden" name="line_item" value="value3">
</form>
有人能帮忙吗?谢谢
抱歉,我忘了提到我没有访问服务器的权限,我需要在appcelerator中解决它。如果您使用PHP作为服务器平台,您可以将POST变量加入到数组中
<form method="POST" action="http://localhost/index.php">
<input type="hidden" name="line_item[]" value="value1">
<input type="hidden" name="line_item[]" value="value2">
<input type="hidden" name="line_item[]" value="value3">
</form>
解决了
var httpClient = Titanium.Network.createHTTPClient();
httpClient.open('POST', 'http://localhost/index.php');
httpClient.send("line_item=value1&line_item=value2&line_item=value3");
对不起,我忘了提到我并没有访问服务器的权限,我需要在appcelerator中解决它。
if (is_array($_POST['line_item[]'])) {
$count = 0;
foreach($_POST['line_item[]'] as $line_item)
echo($line_item . " #" . $count++);
}
var httpClient = Titanium.Network.createHTTPClient();
httpClient.open('POST', 'http://localhost/index.php');
httpClient.send("line_item=value1&line_item=value2&line_item=value3");