Codeigniter使用post和ajax加载视图 [英] Codeigniter Load a view using post and ajax

查看:93
本文介绍了Codeigniter使用post和ajax加载视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个ajax代码:

  $(#comparar)。 b var oTable = $('#propiedades')。dataTable(); 
var sData = $('input',oTable.fnGetNodes())serialize();
console.log ;
$ .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;
});

这是我的控制器:

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

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


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

正常工作,但我可以看到视图,这里的firebug的反应是一个图像



请排除我的英语,

解决方案

thanx Sergiu Paraschiv改变我的成功

  success:function(data){
if(data)
$(body)。
}

p>

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,

解决方案

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

这篇关于Codeigniter使用post和ajax加载视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆