I need to use a dynamic URL in colorbox, but the link
variable is empty. I was tried it without using a function, simply link = data;
, but it is not working.
var link = '';
function getURL(){
$.ajax({
url:"<?echo get_template_directory_uri();?>/designesia/bookAjax.php",
cache: false,
type: "POST",
data: $("#myForm").serialize(),
success:function(data){
link = data;
}
});
}
$(".iframe").click(getURL);
$(".iframe").colorbox({
iframe:true,
width: "50%",
height: "80%",
href: link,
});
The following code is working:
$(".iframe").click(function() {
var link = '';
$.ajax({
url:"<?echo get_template_directory_uri();?>/designesia/bookAjax.php",
cache: false,
async: false,
type: "POST",
data: $("#myForm").serialize(),
success: function(data){
link = data;
}
});
$(".iframe").colorbox({
iframe:true,
innerWidth: "45%",
height: "90%",
href: link,
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments