ajax将内容加载到隐藏div后触发颜色框

时间:2013-10-07 17:32:50

标签: jquery ajax colorbox

ajax将内容加载到隐藏的div后触发颜色框?

                        $('#recipe').on('keyup', function( event ){
                            if(this.value.length == 3) {
                                /* run ajax call, output result to div #check-drink */
                                ajaxRequest('<?php echo SECUREURL; ?>/ajax/ajax-check-drink.php', 'recipe='+$('#recipe').val(), '#check-drink');

                                /* open results from ajax call into colorbox */
                                $('#check-drink').colorbox({inline: true, open: true);
                            }
                        });

2 个答案:

答案 0 :(得分:0)

$('#recipe').on('keyup', function (event) {
        if (this.value.length == 3) {
            /* run ajax call, output result to div #check-drink */
            $.ajax({
                    url: <? php echo SECUREURL; ?> +'/ajax/ajax-check-drink.php',
                    data: {
                        'recipe': $('#recipe').val()
                        success: function (data) {
                            $(#check - drink).html(data);
                            $(#check - drink).colorbox({
                                    inline: true,
                                    open: true);
                            }
                            );

                        /* open results from ajax call into colorbox */
                        $('#check-drink').colorbox({
                                inline: true,
                                open: true);
                        }
                    });

答案 1 :(得分:0)

使用ajax请求的成功回调....我在这里使用$.post

 $.post('<?php echo SECUREURL; ?>/ajax/ajax-check-drink.php', {'recipe':this.value}, function(html){
      //make sure your response is in HTML
      $('#check-drink').html(html);
});