Error:Uncaught ReferenceError: is not defined at HTMLAnchorElement.onclick

+5 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 in Laravel by kartik
• 30,230 points
11,640 views

1 answer 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 by Niroj
• 65,500 points
It work!..thanks man:)
Thank you it helped me

Related Questions In Laravel

+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 in Laravel by Niroj
• 65,500 points
4,791 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 in Laravel by Niroj
• 65,500 points
3,113 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 in Laravel by pakainfo
3,634 views
+1 vote
1 answer

Error:Class '\App\User' not found in Laravel when changing the namespace in Laravel?

Hello @kartik Go to config/auth.php and change App\User:class ...READ MORE

answered Apr 3 in Laravel by Niroj
• 65,500 points
4,481 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 in Laravel by Niroj
• 65,500 points
200 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 in Laravel by Niroj
• 65,500 points
194 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 in Laravel by Niroj
• 65,500 points
86 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 in Laravel by Niroj
• 65,500 points
122 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 in Laravel by Niroj
• 65,500 points
152 views
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 in Laravel by Niroj
• 65,500 points
237 views