0

I'm using CodeIgniter to create a registration form, and I am using AJAX to check if the e-mail address entered has already been used, but every time I check, I get the error 'ReferenceError: finishedAjax is not defined' This is my code:

<script type='text/javascript'>     
    $(document).ready(function() {
        $('#Loading').hide();
        $('#email_address').blur(function () {
            var a = $("#email_address").val();
            var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
            if(filter.test(a)) {
                $('#Loading').show();
                $.post("check_email_availablity", {
                    email: $('#email_address').val()
                }, function(response) {
                    $('#Loading').hide();
                    setTimeout("finishedAjax('Loading', '"+escape(response)+"')",400); 
                });
                return false;
            }
        });

        function finishedAjax(id, response) {
            $('#'+id).html(unescape(response));
            $('#'+id).fadeIn();
        }
    });     
</script>
4

2 回答 2

1

Your finishedAjax function must be outside of document.ready block

于 2013-05-20T09:28:14.703 回答
1

Try to use:

setTimeout(function () {
    finishedAjax('Loading', escape(response));
}, 400); 
于 2013-05-20T09:29:10.510 回答