1
jQuery.validator.addMethod("uniquerheading", function(value, element) {     
        var data = false;
        $action_name = 'checkunquieannoucementheading';

        var url = '<?php echo "$module_name/$controller_name/checkunquieannoucementheading"; ?>';
        $.ajax({
             url: url,
             type: 'get',
             data: {
                "txt_heading":value             
             },
             success: function(data) {              
                // Display list on the page by replacing the content on existing, get from the controller-action
                return data;
             }
        });


}, "Annoucement heading already used");
4

1 回答 1

0

工作代码...只需使用 async: false

jQuery.validator.addMethod("uniquerheading", function(value, element) { 

        $action_name = 'checkunquieannoucementheading';
        var response = false;
        var url = '<?php echo "$module_name/$controller_name/checkunquieannoucementheading"; ?>';
            $.ajax({
            url: url,
            type: 'get',
            data: {
                    "txt_heading":value             
            },
            success: function(data) {               
                // Display list on the page by replacing the content on existing, get from the controller-action
                response =  data;
            },
            async:   false
        })

        return response;

}, "Annoucement heading already used");
于 2013-02-19T05:23:26.110 回答