I would like to send a list of data by ajax. So I push all data in a 2d array
But the ajax of jquery not accept the array data, the data must be object or query string
since the Object of javascript is no push function, I must use array to build the list of data. Is there any function in jquery or javascript, let me
var countLine=$("line").length;
var lines=$("line");
var lineArr=new Array();
var linesArr=new Array();
var x1, y1, x2, y2;
for(i=0; i<countLine; i++)
{
lineArr['x1']=lines[i].getAttributeNS(null, "x1");
lineArr['y1']=lines[i].getAttributeNS(null, "y1");
lineArr['x2']=lines[i].getAttributeNS(null, "x2");
lineArr['y2']=lines[i].getAttributeNS(null, "y2");
linesArr.push(lineArr);
}
$.ajax({
type: "POST",
url: "test.php",
data: linesArr,
async: true,
cache: false,
success: function(data){
$("#txt").text(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert("fail");
}
});