2

I'm trying to get jQuery working in my view but I cannot get a simple alert box to appear!

My _Layout page has the default bundles defined before the closing 'body' tag:

 @Scripts.Render("~/bundles/jquery")
 @Scripts.Render("~/bundles/bootstrap")
 @RenderSection("scripts", required: false)
</body>

At the top of my View have a script section:

@section scripts {
<script type=”text/javascript”>
          $(function() {
      alert("hello");
    });
</script>
}

The source code from the rendered page shows this before the closing 'body' tag:

   <script src="/bundles/jquery?v=Aj1GKhwLcrKGfvkl6W3KyVVaqQJQ2zhPCS3xQ5-_xuE1"></script>

   <script src="/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1">   </script>


<script type=”text/javascript”>
          $(function() {
      alert("hello");
    });
</script>

Why am I not seeing an alert message??

1
  • what error are your getting Commented Jun 10, 2014 at 12:00

1 Answer 1

3

Remove the smart double quotes or should i say curly quotes from here <script type=”text/javascript”>:

@section scripts {
   <script type="text/javascript">
      $(function() {
           alert("hello");
      });
   </script>
}

is different against " double quotes.

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

1 Comment

Jeebus! That was it facepalm

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.