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?

有帮助吗?

解决方案

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top