Codeigniter Load a view using post and ajax

2019-06-04 02:16发布

问题:

I have this ajax code:

$("#comparar").click(function() {
    var oTable = $('#propiedades').dataTable();
    var sData = $('input', oTable.fnGetNodes()).serialize();
    console.log(sData);
    $.ajax({
        type : "POST",
        url : "/zcms/comparar/propiedades",
        data : sData,
        dataType: 'json',
        success: function(){
         $('#profitSignal').modal('hide');
        // window.location="http://btsignals.com/index.php/zcms/performance";
         }
    });
    // cierra ajax contactG

    return true;
});

And this is my controller:

function propiedades()
{
    $data['title'] = 'Comparar Propiedades';
    $data['properties1'] = $this -> zcms_properties_model -> get_property_comparativa();

    $data['main_content'] = 'zcms/comparativa';
    $propertiesdetalle = $data['properties1'];


    //$this->output->enable_profiler(TRUE);
    $this -> load -> view('zcms/template', $data);
}

is working but i can get the view, but i can see the page in the response of firebug here is a image

please excuze my english,

回答1:

thanx Sergiu Paraschiv change my success for

       success: function(data){
    if(data)
$("body").html(data);
}

and this do the trick, thanx for guide me in the right direction