-2

I try to use jQuery and I get Reference Error: $ is not defined. I use Visual studio code and I use Code Runner extension to test the code. My question is do I need to use some sort of import statement at the beginning of the code or install some extension or is there some other way to solve this problem?

I have installed jQuery Code Snippest extension. I tried to use import statement but it leads to error message as well.

    var path = 'https://api.ipify.org?format=json';
    $.getJSON(path, data,
    function (data, textStatus, jqXHR) {
    console.log(data);
    })
ellipsis
  • 12,049
  • 2
  • 17
  • 33

1 Answers1

-1
var script=document.createElement('script');
script.src='jquery path';
script.type='text/javascript';
document.getElementsByTagName('somewhere')[0].appendChild(script);
Blaze
  • 84
  • 5