mTuran mTuran - 5 months ago 24
jQuery Question

Creating Array From Window.location.hash

i am trying to create array from window.location.hash variable but i am failling.

My code is:

$.each(window.location.hash.replace("#", "").split("&"), function (i, value) {
value = value.split("=");

var my_item = {value[0] : value[1]};
form_data[i] = my_item;
});
console.log(form_data);


Thanks.

Answer
your code is correct only error is

 $.each(window.location.hash.replace("#", "").split("&"), function (i, value) {
            value = value.split("=");
            var _formItem={};
            var my_item={};
            my_item[value[0]]= value[1]; 
            form_data[i] = my_item; 
        });