0

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);
                            }
                        });
4

2 回答 2

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);
                        }
                    });
于 2013-10-07T17:40:47.640 回答
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);
});
于 2013-10-07T17:48:57.257 回答