JavaScript jQuery - is not defined- function error

0 votes

I am trying to run a JavaScript/jQuery function and Firebug gets the error:

$ is not defined $(function()".

The JavaScript code is placed inside a file called core.js and referenced by index.php. What causes this error?

JavaScript:

<script type="text/javascript">
    var formObject = {
        run : function(obj) {
            if (obj.val() === '') {
                obj.nextAll('.update').html('<option value="">----</option>').attr('disabled', true);
            } else {
                var id = obj.attr('id');
                var v = obj.val();
                jQuery.getJSON('/mod/update.php', { id : id, value : v }, function(data) {
                    if (!data.error) {
                        obj.next('.update').html(data.list).removeAttr('disabled');
                    } else {
                        obj.nextAll('.update').html('<option value="">----</option>').attr('disabled', true);
                    }
                });
            }
        }
    };

    $(function() {

        $('.update').live('change', function() {
            formObject.run($(this));
        });

    });
</script>

PHP/HTML

<html>
    <select name="main" id="category" class="update">
    <option value="">Select one</option>

        <? if (!empty($list)) { ?>
            <? foreach($list as $row) { ?>
                <option value="<?php echo $row['id']; ?>">
                    <? echo $row['name']; ?>
                </option>

            <? } ?>
        <? } ?>

    </select>
</html>

Jun 6 in JQuery by Edureka
• 13,640 points
74 views

1 answer to this question.

0 votes

You may experience the “jQuery is not defined error” when jQuery is included but not loaded. Make sure that it's loaded by finding the script source and pasting the URL in a new browser or tab. The snippet of text you should look for to find the URL to test.

answered Jun 6 by Edureka
• 13,640 points

Related Questions In JQuery

0 votes
1 answer

Uncaught ReferenceError:Karma: jQuery is not defined

Hii @kartik, You first have to load jQuery ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,740 points
3,003 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

The "$(...).datepicker is not a function" jQuery ...READ MORE

answered Jun 6 in JQuery by Edureka
• 13,640 points
65 views
0 votes
1 answer

Jquery validation plugin - TypeError: $(...).validate is not a function

The "$(...). validate is not a function" ...READ MORE

answered Jun 28 in JQuery by rajatha
• 7,040 points
513 views
0 votes
1 answer

jquery function val() is not equivalent to "$(this).value="?

val() method is primarily used to get the ...READ MORE

answered Jun 14 in JQuery by rajatha
• 7,040 points
8 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,500 points
306 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
8,795 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
15,768 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,740 points
1,282 views
0 votes
1 answer

jQuery fix for "Uncaught TypeError: $ is not a function" error

We can fix this error by using jQuery() . ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
161 views
0 votes
1 answer

$ is not a function - jQuery error

The typeerror: $ is not a function ...READ MORE

answered Jun 6 in JQuery by Edureka
• 13,640 points
45 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP