Question

i need to fill a div with certain content from ajax after fancybox close, on parent page

<div id="ajax-content-here"></div>

So using callback from fancybox Documentation

afterClose : function() {
  //Ajax query here values in json format
}

Function closes the fancybox fine and im getting in my network check all the required data in json format

{value1:1, value2:2, value3:3}

But when i attempt to add it to the div container nothing happens

$("#ajax-content-here").html( data );

Might be a dumb error but i'm a little stuck, any advices?

Was it helpful?

Solution

Pass a parameter to the callback, and check for the dataType on Ajax

afterClose : function() {
    $.ajax({ 
    type: "GET/POST",
    url: "myURL",
            dataType: 'json',
    success: function(data){
         // Handler for data Result
    }
    });     
}

That should do the trick.

OTHER TIPS

Try passing a parameter to the function :

afterClose : function(data) {
  $("#ajax-content-here").html( data );
}

I'm not really sure this is the solution because I'm not that familiarized with jQuery

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top