Asynchronous javascript issue
<p>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.. </p>

<p>is there a way to sync it all so that it works in IE?</p>

<pre><code>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 += "&amp;keyword=" + encodeURIComponent($('#hdnKeyWord').attr('value')); // keyword addition
        qstring += "&amp;pagestart=" + $('#current_page').attr('value'); // pagestart(current page) addition
        qstring += "&amp;pagesize=" + $('#show_per_page').attr('value'); // per page size addition
        qstring += "&amp;facets=" // facetsearch
        $.each(selectedFilter.items, function (index, value) {
            qstring += value.filter + ",";
        });     
        qstring += "&amp;selectedSection=" + selectedSection // Section Select
        return qstring;
    }
</code></pre>
