Thursday, October 18, 2012

Render Element with AJAX Request / Response

My original function to return a JSON array no longer works with v2.1.3

 

This worked in 1.3: loaded a form into a modal window

 

Controller code snip:

if ( empty( $this->data ) ) {

                $this->data = $record; //debug shows the $record so there is data / debug is at 0 now

                $response = array(

                                'status' => true,

                                'title' => $record['Education']['program'],

                                'html' => $this->render());

}

                                                               

$this->_ajaxReturn( $response ); //simply encodes and returns the $response echo json_encode($response);

 

But the html data is no longer being rendered into the JSON response. The fancybox loads but no HTML.

 

The js for the ADD link in the view calls this js:

$(".add").live('click', function (){

                                $.fancybox.showActivity();

                                $.ajax({

                                                type: "GET",

                                                url: $(this).attr("href"),

                                                cache: false,

                                                resetForm: true,

                                                dataType: 'json',                                              

                                                success: function(r) {

                                                                $.fancybox({

                                                                                                'autoDimensions'             :               false,

                                                                                                'opacity' : 1,

                                                                                                'width' : 740,

                                                                                                'margin' : 10,

                                                                                                'padding' : 10,

                                                                                                'content' : r.html});

                                                               

                                                               

                                                               

                                                }

                                });

                                return false;                      

                });

 

 

The JSON response looks like this:

{"status":true,"title":"Auto Generated For Development","html_view":{}}

 

Any ideas?

 

Thanks,

Dave

 

No comments: