IE "Microsoft JScript runtime error: Object expected"

Posted by Stephen Borg on Stack Overflow See other posts from Stack Overflow or by Stephen Borg
Published on 2011-01-11T00:39:57Z Indexed on 2011/01/11 0:54 UTC
Read the original article Hit count: 254

Hi there,

I have problems with regards to javascript only when using IE. The error I am getting is "Microsoft JScript runtime error: Object expected" and I have no idea why. It is then jumping into the JQuery 1.4.2 file, without giving me a proper error message.

All I am doing is simply reading on page load the raw URL, and getting a query string named Search. Using that in an AJAX call to return products and put then into a DIV. No biggies, but somehow IE is managing to blow my page up :-(

Any ideas? Code as follows :

<script type="text/javascript">
    $(document).ready(function (e) {
        $('.boxLoader').show();

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.href);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

        var Search;
        Search = getParameterByName("search");

        $('#searchCriteria').text(Search);

        $.get("/Handlers/processProducts.aspx", { SearchCriteria: Search }, function (data) {
            $('#innercontent').html(data);
            $('#innercontent').fadeIn(200);
            $('.boxLoader').fadeOut(200);
        });

        $('#searchBox').live("click", function () {
            $.get("/Handlers/processProducts.aspx", { SearchCriteria: $('#searchCriteria').val() }, function (data) {
                $('#innercontent').html(data);
                $('#innercontent').fadeIn(200);
                $('.boxLoader').fadeOut(200);
            });
        });
    }); 
</script>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery