以下代码显示加载页面时加载了ajax的页面。但是,我不知道如何在ajax文件中加载PHP。有人可以帮忙吗?
/* <![CDATA[ */
// call fancybox
function openFancy(){
setTimeout( function() {$('.fancybox').trigger('click'); },0);
}
// create cookie on button click
function dontShow(){
$.fancybox.close(); // optional
$.cookie('visited', 'yes', { expires: 30 }); // expiration in 30 days
}
$(document).ready(function() {
var visited = $.cookie('visited'); // create cookie 'visited' with no value
if (visited == 'yes') {
return false;
} else {
openFancy(); // cookie has no value so launch fancybox on page load
}
$('.fancybox').fancybox({
scrolling : 'no',
width : '100%',
fitToView : true,
closeBtn : false,
padding : 0,
margin : 20,
locked : false,
scrollOutside : false,
closeClick : false,
helpers : { overlay : {
closeClick: false,
locked: true},
}
});
}); // ready
/* ]]> */
答案 0 :(得分:1)
试试这个:
对于链接(HTML)
<a id="fancybox_ajax" href="overlay.php"></a>
对于fancybox的设置:(JS)
$("#fancybox_ajax").fancybox({
scrolling : 'no',
width : '100%',
fitToView : true,
closeBtn : false,
padding : 0,
margin : 20,
locked : false,
scrollOutside : false,
closeClick : false,
helpers : { overlay : {
closeClick: false,
locked: true},
},
//This is what you have to add
ajax : {
type : "POST",
//This is optional if you want to pass some data
data : 'key=value'
}
});
祝你好运! ^^