我可以帮您翻译成中文。这段代码是将数组存储在一个隐藏的标签中,以下是代码:
(注:本文中涉及的技术词汇,如有需要请自行查阅相关资料)
Javascript:
var trees;
// called when the body loads
function BodyOnLoad()
{
trees = document.getElementById("trees");
trees.value = new Array();
}
// this is what isn't working
function AddTree()
{
var i = trees.value.length;
trees.value[i] = new Array();
/***/
trees.value[i]["branches"] = 5;
trees.value[i]["trunk"] = 0;
}
HTML: <input type="hidden" name="trees" id="trees" />
在C#中,Request.Form["trees"]
不是一个数组。我做错了什么?
(注:本文中涉及的技术词汇,如有需要请自行查阅相关资料)
JSON.stringify
在IE浏览器中不可用...以这种形式。最好使用JavaScript库来完成此操作,例如jQuery。(编辑-我的错,jQuery不支持此功能...请查看https://dev59.com/T3VC5IYBdhLWcg3ww0Hr 了解如何序列化JSON) - Miguel Angelo