views:

34

answers:

1

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

+2  A: 

.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.

Nick Craver
The [ **MDC reference for `.join()`** ](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/join)
Peter Ajtai