开发者

Serializing a javascript array with Jquery

I have the following code:

<script type="text/javascript">
var checksSinceLastPostBack = new Array();

function clientSelectedIndexChanged(sender, eventArgs) {
    var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
    var serializedCheckData = checksSinceLastPostBack.serializeArray();

    if (ajaxManager != null)
        ajaxManager.ajaxRequest(serializedCheckData);
}
</script>
开发者_如何学编程

The

var serializedCheckData = checksSinceLastPostBack.serializeArray();

doesn't seem to work. Am I misunderstanding this?

Also if this works, how would I deserialize it in the code behind?

EDIT: Sorry, this is in ASP.NET


.serializeArray() is for serializing form elements with name/value pairs, not a normal Array. To convert that to a string you want something like:

var serializedCheckData = checksSinceLastPostBack.join(',');

...or some other delimiter. If you have more complex data you may want to go a JSON route.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜