简体   繁体   中英

Javascript function: Uncaught ReferenceError: potDeposit is not defined

I understand a syntax issue may cause this, but I haven't found any syntax issues in my code.

    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <script type="type/javascript">
        function potDeposit(id) {
            var depo = document.getElementById('deposit' + id);
            jQuery.get("ajax/potdeposit.php?id=" + id + "&amount=" + depo.value, function(data) {
                depo.value = '';
                if(data == '1') {
                    document.getElementById('error' + id).innerHTML = 'Insufficient Funds!';
                }else if(data == '2') {
                    document.getElementById('error' + id).innerHTML = 'Your account has been locked!';
                }else if(data == '3') {
                    document.getElementById('error' + id).innerHTML = 'Server Error! Pot doesn\'t exist.';
                }else if(data == '4') {
                    document.getElementById('error' + id).innerHTML = 'twarks.';
                }
                refreshPots();
            });
        }

        function refreshPots() {

        }
    </script>

Error from both Firebug & Chrome: Uncaught ReferenceError: potDeposit is not defined

To declared javascript script, correct type is : text/javascript . You declared your script with type/javascript . It should have been this:

<script type="text/javascript">

instead of:

<script type="type/javascript">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM