cppit
cppit

Reputation: 4564

fancybox is not requesting the proper page using ajax

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

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

so this is my code, when I use firebug I see that the data is being passed (under parameters) but the url requested is the same file index.php instead it should say requestajax.php?cid=3 any ideas ? I think I am doing something wrong. the modal box is loaded with the index.php content instead of requestajax.php. thats issue

Upvotes: 0

Views: 248

Answers (2)

Janis
Janis

Reputation: 8769

Try setting your URL as href parameter:

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

Upvotes: 2

John Skoubourdis
John Skoubourdis

Reputation: 3259

I think that the

URL: 'requestajax.php',

has to be in lowercase like this:

url: 'requestajax.php',

Anyway you have to be careful with the options in JavaScript as onStart is different from onstart.

If this is not the case then try to add an absolute url to your fancybox, for example:

url: '/requestajax.php',

Upvotes: 0

Related Questions