Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables appcelerator post请求。在一个请求中多次发送一个变量。_Variables_Post_Appcelerator - Fatal编程技术网

Variables appcelerator post请求。在一个请求中多次发送一个变量。

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">

你好!我想在一个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">
    <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");