Monday, November 17, 2008

Microsoft JScript runtime error object expected with jQuery

I was trying to get a simple piece of jQuery to work and was running up against this error in Internet Explorer (IE):

Microsoft JScript runtime error: object expected

The problem turned out to be that I wasn't referencing jQuery to the correct path. The trick I discovered, if you're using Visual Studio, is to just drag the JavaScript file from the Solution Explorer into the <head> element on your page and it will insert the correct reference for you.

UPDATE (9 July 2009):

I am referencing jQuery from the Google CDN now:

<script src=""></script>
        google.load("jquery", "1.3.2");
        google.load("jqueryui", "1.7.2");

Using this technique will also get rid of this error and improve performance.

The first reference to jQuery (1.3.2) is for the core jQuery library. The second reference to (1.7.2) is for the optional jQuery UI library that you will only need if you are using the UI components/elements of the jQuery library. If you are using jQuery to manipulate the DOM only then you won't need the UI reference.



  1. make sure the script tag in the head tag that references jquery ends with '</script>' and not '/>'. the same as dragging the script file onto your markup

  2. Search the problem , your page came up.
    Worked for me ... thank you.

  3. Thanks Amjad and Ellis, found you after breaking my head for nearly 10 hours on this error and your solution worked. You guys rock!!!!!

  4. Amjed, half a day of my precious life already had gone down the drain trying to get Jquery to work in a dummy web app. Your information saved further time being lost, much appreciate it.
    Ellis, thanks for sharing info on using declarative syntax to refer to a particular version of jquery.

  5. Good Information, saved my time.
    Thanks Amjed and ellis.

  6. Worked for me! Thanks very much

  7. I spent so much time trying to 'debug' this and with a simple drag and drop, my link now works!

  8. You hit the error eactly. It hlped me a lot. thanks

  9. Just can not THANK you enough.
    This stupid error drove me crazy for days.

  10. Thanks a million .... ! I could help my friend solve this issue which has been consuming him for days :)

  11. Thanks a lot ... I have spent so much time before I found your usefull page!!!!!

  12. I am having the same issues using Internet Explorer 8. FireFox has no issues. Any project i use for Jquery or silver light has issues
    I downloaded open source projects from . Give the same error "Microsoft JScript runtime error: '$.jgrid' is null or not an object"
    Another application from gives the same error.
    Any advice would be helpful

  13. I have this problem in ie 6 but when I copy the .js files to local machine and refer it in the script tag it works fine.
    I am trying to make use of through my visual studio editor and facing this problem.
    As per your guidance if I am referencing "" then from where should I drag this?. if its a local file then I can drag it from the solution explorer but if am referencing google or aspnetcdn then how do I drag that URL?
    Please help.

  14. @Saami - If you're trying to get intellisense in Visual Studio then you need a local copy of the jquery-1.4.1-vsdoc.js file and you would drag that onto your view.
    If you're just trying to use jQuery in a production style environment then you would copy the above code into your .master file or view.

  15. perfect...thank you very much. Drag n drop did not work for me but adding links from google did.

  16. Thanks a lot, after dragging the jquery its works fine

  17. Of course, on my development machine had high security settings so jquery would not work!
    Reset IE security settings a bit lower and it worked!
    A good tip if your developing on server 2008 which has high security within IE by default.

  18. Thank you for this article. I just want to notice that make sure you don't forget to include you jquery.min file, because I forgot and it did not work.
    So final solution:
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.load("jqueryui", "1.7.2");
    <script type="text/javascript" src="path/to/your/jquery/file/jquery.min.js"></script>

  19. Thanks, it worked. I later found that if you don't want to reference an outside link, you can try adding
    <allow users="?"/>
    to your Web.config. If you're already blocking anonymous users, one trick is to create a second Web.config in your Scripts folder with that authorization.
    Courtesy of

  20. hi,
    great post and it's worked fine for me