Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Fancybox POST
#1

[eluser]RobertB.[/eluser]
Hello guys,
Any idea why this is not posting anything?
In the firebug's post tab nothing shows.
This only happens with fancybox.

The idea is to get all checked checkboxes ids in the fb div

Code:
$('#fb-submit').live('click', function() {
  $.ajax({
     type: "POST",
     dataType: "json",
     cache: false,
     url: "",
     data: $('#fb input[type=checkbox]:checked').serialize(),
     success: function(data) {
       $.fancybox(data);
     }
  });
});

Thanks
#2

[eluser]danmontgomery[/eluser]
You have to give it a URL to post to:

Code:
url: "",
#3

[eluser]RobertB.[/eluser]
noctrum, my problem is that I can't post.

I can do this and get a response.

JS
Code:
$('#fb-submit').live('click', function() {
        $.ajax({
            type: "POST",
            dataType: "json",
            cache: false,
            url: "services/update",
            data: $('#fb input[type=checkbox]:checked').serialize(),
            success: function(data) {
                $.fancybox(data);
            }
        });
    });

CONTROLLER
Code:
function update() {
        $data = 'Test';
        
        echo ($data);
    }

This will produce a fancybox popup with the word Test in it.

This code is no posting anything, is like the #fb div does not exits but it does, I also try the native fancybox div #fancybox-content and still nothing.

this is the part that is not working.
Code:
data: $('#fb input[type=checkbox]:checked').serialize(),

or

Code:
data: $('#fancybox-content input[type=checkbox]:checked').serialize(),

Thanks
#4

[eluser]eoinmcg[/eluser]
as far as i can see there are a few places where problems could be occuring.

firstly, i recommend you use firebug for debugging, that way you can see what is being posted via ajax.

secondly, is your fancybox form opening a new page in an iframe? if so make sure you're also loading jquery on that page or access it via parent.$

also, from your above example, dataType: json, means that jquery expects output returned as json. your controller, however, is outputting html, which will throw an error. in my experience best to omit this as the default behaviour is 'intelligent guess, which usually works well.

hope that helps
#5

[eluser]RobertB.[/eluser]
Hey guys thank you all for replying but perhaps I'm not explaining what is happening correctly.

I'm using firebug for debugging.
The code the I'm using works fine if I'm not using Fancybox.
The only problem I'm having is that the code is not POSTING the data.

Right now I don't care about getting anything return I just want to see something posted.

This code does not post anything
Code:
$('#fb-submit').live('click', function(){
     $.ajax ({
     type: "POST",
     data: $('#fancybox-content input[type=checkbox]:checked').serialize()
     });
   });

This code post Testing
Code:
$('#fb-submit').live('click', function(){
     $.ajax ({
     type: "POST",
     data: 'Testing'
     });
   });

That is why I'm saying that the problem is in this part of the code
Code:
data: $('#fancybox-content input[type=checkbox]:checked').serialize()

I can't get the content of the fancybox-content div to post is the only problem I'm having right now.

Remember that I'm submitting from inside a fancybox popup. I already populate a fancybox with checkboxes an a submit button to update records.

I'm gonna try the $.parent() code that you were talking about and see what happens
#6

[eluser]danmontgomery[/eluser]
http://groups.google.com/group/fancybox?pli=1
http://forum.jquery.com/
#7

[eluser]carbona[/eluser]
Are you tring to post from within the fancybox or from the parent page itself?
Remeber that if you close the fancybox popup then the content from div with id fancybox-content will be emptied.
#8

[eluser]ELRafael[/eluser]
Try to open the fancybox "pop-up" as iframe.
#9

[eluser]RobertB.[/eluser]
Thanks guys,
noctrum: Yesterday I posted on that group, let see if is as active as this forum
carbona: I'm posting from within the fancybox.
ELRafael: Let me try and do that.
#10

[eluser]RobertB.[/eluser]
Hey again,
After a long break from this and unable to get help from fancybox support.
I figure out that I can't use the serialize() function, don't ask me why but if I don't use it then I can post.

This is how I'm posting
Code:
$('#fb-submit').live('click', function(){
   var data = $('#fb input[type=checkbox]:checked');        
   $.post("", data);        
}, "json");

This code post the desired data (the ids of the checkboxes that are checked)
However I don't know how to attach a prefix to the results

I'm getting something like this "=5&=2" and I want something like this "id=5&id=2"

If I try this

Code:
$.post("", "id=" + data);

Then I get this in firebug post tab

Code:
id=[object Object]

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB