0

I have created a .Net Core 1.0 MVC project. I am using TypeScript files. I want to transmit some data using the jquery call $.ajax but the compiler does not recognised the dollar sign. I have tried various permutations of...

import * as $ from "../lib/jquery/dist/jquery";

...but to no avail. TypeScript files that do not call jquery functions work perfectly. When I put the $.ajax call on the view using javascript it works fine. However, I want to use TypeScript for obvious reasons. Could someone suggest the correct reference please?

5
  • Possible duplicate of How to import JQuery into a Typescript file? Commented Sep 28, 2017 at 12:18
  • Possible isn’t good enough if you don’t provide a link! Commented Sep 29, 2017 at 19:47
  • Apologies - I could not see the link on my phone screen. Sorry again. Commented Oct 2, 2017 at 5:37
  • Vijayanath pointed me in the right direction. I downloaded a copy of jquery.d.ts from here... github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/… and manually loaded it into my lib folder and then placed this line at the top of the TypeScript file... /// <reference path="../lib/jquery.d.ts" /> Now this symbol $.ajax compiles. Commented Oct 2, 2017 at 5:43
  • good to know your problem solved. Please up flag my comment if it helped. Thank you Commented Oct 2, 2017 at 6:16

0

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.