The problem is I want to send ajax array to a php where I can use it for different processing, actually I have a lot of text fields in my html page and I have assign them name I want to send this name array to my php page through ajax(JavaScript only) where I will receive this array and will use it for different purposes.
Here is my example HTML code:
<input type="text" name="top_phone_cal2" class="form-control" >
<input type="text" name="top_phone_cal2" class="form-control" >
<input type="button" onclick="dis_phone_call2_top()" class="form-control" >
JavaScript code:
function dis_phone_call2_top()
{
var x =document.getElementsByName('top_phone_cal2');
var top_phone_cal2 = [];
for(i=0;i<x.length;i++)
{
top_phone_cal2[i]=x[i].value;
//alert("cars value: "+top_phone_cal2[i]+" loop value: "+x.length);
}
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var bbb=xmlhttp.responseText;alert(bbb);
}
}
xmlhttp.open("GET", "intervention_phonecal2_insrt.php?value="+top_phone_cal2, true);
xmlhttp.send();
}
Here is php code:
<?php
$top_phone_cal2= $_REQUEST["value"];
echo $top_phone_cal2;
?>
The problem in this code is that through this code I am unable to receive array in php page instead of this I receive the variable in php page
For Example:
if in first text field I entered Johnand in second text field I entered lincon then in page it display it like this johnlincon but I want to display I like this echo $top_phone_cal2[0]=john and echo $top_phone_cal2[1]=lincon
kindly tell me how to do this?
ajax array. Read about how HTTP protocol works in general, then about particular implementations for your needs.