I have a form with 2 inputs as below. I am sending POST request through ajax
<input name="item_name[]" value="Monthly" id="i1"/>
<input name="item_name[]" value="Weekly" id="i2" />
xmlhttp.open("POST","validation.php",true);
var params = "item_name="+document.getElementById('i1').value+"item_name="+document.getElementById('i2').value;
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
When i submit the page in php, i am not able to read both values. The array shows only one character of the first value.
echo '1.'.$_POST['item_name'][0].' 2.'.$_POST['item_name'][1];
Output is : 1.M 2.o
Expected output is 1.Monthly 2.Weekly
Even , i tried printing $_POST['item_name']
, it shows Monthly only.
Chrome --> Developer Tools --> Gives proper output as well. I dont know where the problem is ?