0

I'm back at coding som .NET stuff and I thought I'd play with Javascripts / jQuery.
I've added my /js/myscript.js file and it loads when the pages has loaded.

In my js file I only have one call alert('TEST').

Why isn't the alert triggered?

I'm on ASP.NET 4.0 - but I don' think that has anything to do with it.
Is there a way to detect if there is any conflict with other scripts?

This goes in the header:

<script type="text/javascript" src="js/myscript.js" ></script>

After page is loaded, I can use Firebug and exapnd the script and see it's content. So the script is loaded.

Embarrassing update

jQuery(document).ready(function() {
    // Alert if jQuery is loaded
    alert('Test1');
}

alert('Test 2');

As you can see in the above code, I'd forgotten to add the ); and the end of the jQuery(document).ready() function.

After a long day, even the simplest things can go unnoticed.

11
  • 2
    Can you show how you've added it? Commented Aug 18, 2011 at 13:15
  • 1
    can you post your javascript code please? Commented Aug 18, 2011 at 13:20
  • what is the javascript code in the file which calls the alert? Commented Aug 18, 2011 at 13:21
  • 3
    @jbabey - This is such a noob error. I'd forgotten to add the ); on the jQuery(document).ready() function. Commented Aug 18, 2011 at 13:22
  • if you add a semi colon: alert('TEST'); does it work then? Commented Aug 18, 2011 at 13:25

2 Answers 2

1

Always check for Javascript Errors on something like this. All modern browser have built in HTML/Javascript inspectors which you can use to check for these errors.

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

1 Comment

I alwys do. But this time Firebug console was not enabled and therefore it never reported the error. That's why I thought it was a .NET / Visual Studio thing. Enableing it gives me the warning.
0

What does your myscript.js look like?

function x(){
  alert('TEST');
}

or just (which will execute on load):

alert('TEST');

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.