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.
Give this a try:
var hash = window.location.hash.slice(1);
var array = hash.split("&");
var values, form_data = {};
for (var i = 0; i < array.length; i += 1) {
    values = array[i].split("=");
    form_data[values[0]] = values[1];
}
console.log(form_data);
...Of course I suspect you may be wanting the search property, rather than hash, but I don't know your specific use case.
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; 
        });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With