0

My code has started giving an "object expected" javascript error, though it was working well before. It is still working fine in another solution.

I have tried changing the contents of the rest of the code, and I am still getting the exception. The script giving the exception is the following:

< script type="text/javascript" charset="utf-8" >
$(document).ready(function ()
{     
   ////code comes here
});
< /script >
3
  • 2
    What line is the exception on? unless you do not have jQuery loaded there is no reason why the code shown should not work. Commented Dec 8, 2011 at 18:22
  • the exception is coming in first line only $(document).ready(function() jQuery is loaded for sure as the same code is working fine in another solution. Commented Dec 8, 2011 at 18:25
  • 4
    Maybe the jquery code is loaded after this snippet. Commented Dec 8, 2011 at 18:33

3 Answers 3

1
<!DOCTYPE html>

<html>

<head>

  <style>p { color:red; }</style>

  <script src="http://code.jquery.com/jquery-latest.js"></script>

  <script>

  $(document).ready(function () {

  $("p").text("The DOM is now loaded and can be manipulated.");

});

  </script>

</head>

<body>

  <p>Not loaded yet.</p>

</body>

</html>

Check your code. have you forgot to add Jquery or have add your function before calling the jQuery. http://api.jquery.com/ready/

Sign up to request clarification or add additional context in comments.

Comments

0

Try something like this:

(function($) { //your code here })(jQuery);

Comments

0

Had some extra handellers in web.config... Problem is resolved after removing the handellers. Rest everything was fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.