[英]Trigger colorbox after ajax has loaded content into hidden div
在ajax將內容加載到隱藏的div后觸發colorbox?
$('#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);
}
});
$('#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);
}
});
使用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);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.