我有三个div,如何仅在特定的div中加载数据而不重新加载php-codeigniter中的整个页面? [英] I have three div's, how to load data in only a particular div without reloading the complete page in php-codeigniter?

查看:107
本文介绍了我有三个div,如何仅在特定的div中加载数据而不重新加载php-codeigniter中的整个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个div标签,单击链接后,我只想在第二个div中加载数据而不加载整个页面,我想将第一个和第三个div保持为静态,而第二个div应该是动态的?

>

   <div class="first">

   <a href="patientLogin/patientVisit_details/<?php echo $data->patient_visit_id;?>"><?php echo $data->hospital_name;?></a>

   </div>


   <div class ="second">
   //content//
   <div>


   <div class ="third">
   //content//
   <div>

解决方案

您可以通过ajax实现这些功能.

1) As you want to apply dynamic data loading on some click event of some anchor link then please don't apply anchor link as:
"<a href="patientLogin/patientVisit_details/<?php echo $data->patient_visit_id;?>"><?php echo $data->hospital_name;?></a>" the anchor leads you to the href value link. alternatively you can do like (<a href="javascript:void(0);">);

现在就您的CI而言; 鉴于:

<a href="javascript:void(0);"onclick="javascript:changeData('<?php echo $data->patient_visit_id;?>')"><?php echo $data->hospital_name;?></a>

在Js文件中

function changeData(parentVisitId){

 var urlCI = 'patientLogin/patientVisit_details/'+parentVisitId;

 $.ajax({
        type: "GET",
        url: urlCI,
        data:{
            'parenIdIfReq':parentVisitId,
        },
        success: function(response) {
            if(response!=''){
                $('.second').html(response);
            }
            else{
                return false;
            }
        }
    });

}
In controller/action i.e patientLogin/patientVisit_details/parentVisitedId
 function patientVisit_details($parentVisiteId){
    echo "whatever data you want to return as response";
 }

I have three div tags, on click of a link I want to load data in only the second div without loading the complete page, I want to keep the first and third div as static and second div should be dynamic?

   <div class="first">

   <a href="patientLogin/patientVisit_details/<?php echo $data->patient_visit_id;?>"><?php echo $data->hospital_name;?></a>

   </div>


   <div class ="second">
   //content//
   <div>


   <div class ="third">
   //content//
   <div>

解决方案

You can achieve these by ajax.

1) As you want to apply dynamic data loading on some click event of some anchor link then please don't apply anchor link as:
"<a href="patientLogin/patientVisit_details/<?php echo $data->patient_visit_id;?>"><?php echo $data->hospital_name;?></a>" the anchor leads you to the href value link. alternatively you can do like (<a href="javascript:void(0);">);

Now in your case for CI; In view:

<a href="javascript:void(0);"onclick="javascript:changeData('<?php echo $data->patient_visit_id;?>')"><?php echo $data->hospital_name;?></a>

In Js File

function changeData(parentVisitId){

 var urlCI = 'patientLogin/patientVisit_details/'+parentVisitId;

 $.ajax({
        type: "GET",
        url: urlCI,
        data:{
            'parenIdIfReq':parentVisitId,
        },
        success: function(response) {
            if(response!=''){
                $('.second').html(response);
            }
            else{
                return false;
            }
        }
    });

}
In controller/action i.e patientLogin/patientVisit_details/parentVisitedId
 function patientVisit_details($parentVisiteId){
    echo "whatever data you want to return as response";
 }

这篇关于我有三个div,如何仅在特定的div中加载数据而不重新加载php-codeigniter中的整个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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