0
$(document).ready(function() {
        $(".modalbox").fancybox({

  type: 'ajax',
  ajax : {
        type    : "GET",
        URL: 'requestajax.php',
        data    : {cid:'3'},
        error: function(){
    alert('failure');
  }
    }
});

所以这是我的代码,当我使用 firebug 时,我看到数据正在传递(在参数下),但请求的 url 是同一个文件 index.php 而它应该说 requestajax.php?cid=3 任何想法?我想我做错了什么。模态框加载了 index.php 内容而不是 requestajax.php。那是问题

4

2 回答 2

2

尝试将您的 URL 设置为href参数:

$(".modalbox").fancybox({
    href : 'requestajax.php',
    type : 'ajax',
    ajax : {
        type  : "GET",
        data  : {cid:'3'},
        error: function(){
            alert('failure');
        }
    }
});
于 2012-11-04T12:43:17.017 回答
0

我认为

URL: 'requestajax.php',

必须是这样的小写:

url: 'requestajax.php',

无论如何,您必须小心 JavaScript 中的选项,因为 onStart 与 onstart 不同。

如果不是这种情况,请尝试将绝对 url 添加到您的 fancybox 中,例如:

url: '/requestajax.php',
于 2012-11-04T00:54:09.143 回答