2

I'm trying to get jQuery working in TypeScript. I'm missing something obvious, but don't see it. I need another pair of eyes.

I created an empty TypeScript project in VS2015.

I added the script tag for jquery:

<script src="http://code.jquery.com/jquery-2.1.4.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>

In app.js, I added the line to get Intellisense

/// reference path=".\Scripts\typings\jquery\jquery.d.ts"/>

Then I call a jQuery function in window.onload

$.get('http://somesite.com/someCSV.txt', function (data) {
    var txt = document.getElementById('TextArea1');
    txt.textContent = data;
        }, 'text');

When I run it, I get an error that $ is undefined.

I missed something. What did I miss?

-- thanks!

1 Answer 1

1

What did I miss?

Check that JQuery.js was actually downloaded (there might have been an outage).

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

2 Comments

yes, that was it. No changes and it's working now. thanks!
I think Visual Studio is caching web pages somewhere. F5 seems to execute old code frequently for me (but not every time). Restarting VS resolves the issue as does executing the html directly in the browser. That may have been the issue; it's hard to say now.

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.