Problems with: Uncaught Referenceerror: $ is not defined

Asked

Viewed 74,733 times

4

There is a doubt in this forum here, but it doesn’t solve my problem. I have includes, including include jquery in the first line because link found this:

Because, JS interpreter search for $ before is Even Loaded and defined.

My mistake is the title of this post. Check it out. In the same file I have include, the function and the call button

<head>
<title><%=Application("app")%></title>

<script type="text/javascript" src="../../gen/modal/jquery-ui.min.js"></script>
<link href="\gen\css\css002.css" rel="stylesheet" type="text/css">

<!-- Include the code and stylesheet for the grid control. -->
<script language="jscript.encode" src="../../gen/inc/ebagrid.js"></script>
<link type="text/css" rel="stylesheet" href="../../gen/inc/styles/xp/eba.css" />

<script src="../../gen/js/cpaint2.inc.compressed.js" type="text/javascript"></script>

</head>

Here’s the function call button. It’s commented on why I’m creating it now and seeing if it’s loading from the bank and so on:

<div><input type="button" id="btn" value="teste" onclick="CarregaTabela();" /></div>

And here the javascript function with jquery. The function is called Table Load:

<script language="javascript">
    var carregaDados = null;

    function reexecute() {
        document.form01.action = '<%=session("pgm_retorno")%>';
        document.form01.submit();
    }

    function CarregaTabela() {
        var str = "";
        $.ajax({
            url: '../../prs/asp/prs0061b_crosbrowser.asp',
            datatype: 'json',
            contentType: 'application/json; charset=utf-8',
            type: 'POST',
            data: JSON.stringify({carregaDados: rsPesquisa}),
            success: function (data) {

                alert(data.carregaDados.nome_tipo_prestador);

                $(data.resultado_acao).each(function () {

                    //str += '<option value=' + this.Acao1 + '>' + this.Acao1 + '</option>';
                })

                //$('#cbxAcao').html(str);

                str = "";

            },
            error: function (error) {
            }
        })
    }
</script>
  • At first it seems to be missing jQuery import before the jquery-ui.min.js. They’re not the same.

  • @Kaduamaral, I thought jquery ui-min was enough. What should I include? What import. Put your comment as an answer, in case you decide to mark your answer.

  • @pnet seems to lack the Jquery reference. Include it before all Scripts.

1 answer

14


Missing to perform jQuery import, example:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>

Or download the file from the jQuery website and import:

<script src="meusjavascripts/jquery-2.1.3.min.js" type="text/javascript"></script>

Obs.: Versions 2.x of jQuery do not support versions below 9 of Internet Explorer (i.e.: IE8, IE7, IE6, etc.). If you don’t have control of your users' browsers use the latest 1.x version.

  • 2

    Thanks, solved the problem of $ is not defined.

  • 1

    Beauty @pnet, good luck on this long web development journey... :v ;)

  • in wordpress where it should be added to load first? In HEADER ??? You would have to make a call in functions.php ????

  • Hi Paulo, I’ve never worked with Wordpress, but I found this link that might help you: https://stackoverflow.com/questions/11159860/how-do-i-add-a-simple-jquery-script-to-wordpress

Browser other questions tagged

You are not signed in. Login or sign up in order to post.