开发者

PHP equivalent of $array[] in javascript

I am trying to pass an arbitrary amount of arrays from my javascript to a php file with json through ajax, the problem word is arbitrary, assume following allmost-development-code

v开发者_如何学Goar arrayContaingAll;

$("li", "#list").each(function()
{
  var a = array( $(".name",this).val(), $(".unit",this).val(), $(".amount", this).val() );
  arrayContainingAll[] = a;
});

however, the [] functionality on an array does not work for me, how would i go around implementing such feature?

Yes, i know PHP damaged me thinking that way


arrayContainingAll.push(a); //equavalent in JavaScript to PHP's arrayContainingAll[] = a;


var arrayContaingAll=[];

$("li", "#list").each(function()
{
  var tempArray=[];
  tempArray.push($(".name",this).val());
  tempArray.push($(".unit",this).val());
  tempArray.push($(".amount",this).val());
  arrayContainingAll.push(tempArray);
});

//arrayContaingAll is ready

//to optimize ur code you may cache li like this inside each

var li= $(this);
tempArray.push(li.find('class_Name'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜