Error Uncaught ReferenceError is not defined at HTMLAnchorElement onclick

+6 votes

I tried to show modal using jquery, but to no avail.

I've tried to rearrange my jquery place and researching through other questions but I can't find any answer to my problem.

Here's the button

<div class="col-sm-6">
    <a onclick="addmhsForm();" href="#" class="btn btn-success" data-toggle="modal"><span>Tambah Mahasiswa</span></a>
</div>

Here's where I place my script and jquery

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
        <script type="text/javascript" src="{{asset('js/api.js')}}"></script>
    </body>
</html>

And here's my custom javascript

$(document).ready(function() {
    //Here's where I place ajax script
});

function addmhsForm() {
    $(document).ready(function() {
        event.preventDefault();
        $("#add-error-bag").hide();
        $('#addModal').modal('show');
    });
}

I expect the code to show the modal, alas what I find is an error message like this:

Uncaught ReferenceError: addmhsForm is not defined at HTMLAnchorElement.onclick
Apr 14, 2020 in Laravel by kartik
• 37,520 points
66,275 views

2 answers to this question.

0 votes

Hello,

With my limited understanding, I tried to bruteforce my way to solve this problem and turns out the culprit is a HTML tag namely

Textarea

This Problematic Code

<textarea type="text" class="form-control" name="alamat" id="alamat"/>

The Solve

<textarea type="text" class="form-control" name="alamat" id="alamat"></textarea>

Hope this work!!

Thank You!!

answered Apr 14, 2020 by Niroj
• 82,840 points
It work!..thanks man:)
Thank you it helped me
0 votes

The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading

answered Dec 14, 2020 by Gitika
• 65,770 points

Related Questions In Laravel

0 votes
1 answer

How to check request is ajax or not in Laravel?

Hello, Laravel allow use of their library method that ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
13,199 views
+1 vote
1 answer

Error [PDOException]: Could not Find Driver in PostgreSQL?

Hii, I got this problem too. I have ...READ MORE

answered Mar 31, 2020 in Laravel by Niroj
• 82,840 points
30,032 views
+2 votes
1 answer

Error: laravel.log could not be opened?

Hello, Never use 777 for directories on your ...READ MORE

answered Apr 2, 2020 in Laravel by Niroj
• 82,840 points
12,427 views
0 votes
2 answers

Error:Class 'App\Http\Controllers\App\Model' not found?

Class ‘App\Http\Controllers\Auth’ Not Found in Class ‘App\Http\Controllers\Auth’ not ...READ MORE

answered Aug 6, 2020 in Laravel by pakainfo
17,637 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,840 points
1,693 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,840 points
1,473 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,840 points
1,033 views
0 votes
1 answer

What are the important directories used in a common Laravel application

Hey @Kartik. Directories used in a common Laravel ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,840 points
2,438 views
0 votes
1 answer

Error:Laravel [InvalidArgumentException] Script “post-install-cmd” is not defined in this package

Hello @kartik, Do composer global update before laravel new <project-name> and you'll ...READ MORE

answered Apr 6, 2020 in Laravel by Niroj
• 82,840 points
1,505 views
0 votes
1 answer

Error: The requested URL /login was not found on this server. Apache (Ubuntu) Server at mydomain.com Port 80

Hello @kartik,  your directory path is wrong. You ...READ MORE

answered Nov 12, 2020 in Laravel by Niroj
• 82,840 points
14,038 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP