Asynchronous javascript issue
- by amit
I am trying to create a function which takes values from various html elements of the page to create a string and pass on to a variable. now this works great for all browsers except IE 8 and 9. IE tends to skip the part of fetching the values and goes straight to the variable and finds nothing.. 
is there a way to sync it all so that it works in IE?
function seturl() {
        var qstring = returnQString();
        $('span.keyword').text($.trim($('#hdnKeyWord').attr('value')));
        $('input.search_box').attr('value', $.trim($('#hdnKeyWord').attr('value')));
        $('#hdnSearchKeyword').attr('value', $.trim($('#hdnKeyWord').attr('value')));
        $(".search_box").val($.trim($("#hdn_span_hdnKeyWord").text()));
        $(".header_inner input[type='text']").focus();
        $(".search_term input[type='text']").focus();
        $('#locationurl').attr('value', qstring);
    }
    function returnQString(){
        var qstring = $.trim($('#locationurl').attr('init')); //initial value of the url
        qstring += "?type=" + $('#hdnSTSearch').attr('value'); // type of handler hit
        qstring += "&keyword=" + encodeURIComponent($('#hdnKeyWord').attr('value')); // keyword addition
        qstring += "&pagestart=" + $('#current_page').attr('value'); // pagestart(current page) addition
        qstring += "&pagesize=" + $('#show_per_page').attr('value'); // per page size addition
        qstring += "&facets=" // facetsearch
        $.each(selectedFilter.items, function (index, value) {
            qstring += value.filter + ",";
        });     
        qstring += "&selectedSection=" + selectedSection // Section Select
        return qstring;
    }