duannai5858 2019-06-14 07:22
浏览 63

将动态数据从控制器传递到具有已定义脚本的视图,该脚本使用该动态数据加载php视图

I am new to MVC and working on a video calling facility between two parties where an admin schedules a call between two the two parties and stores the randomly generated room number in a table.

Okay some background first, there are some patients and a doctor. An admin schedules a call between them. Whenever a patient or a doctor clicks on video call first an ajax query calls a function and checks if there is an entry for the patient/doctor using their id's in the schedule table and if it's there it calls the video chat view.

So to set up video calling I have used a script in the views page which randomly generates a room number(Here I need to get that room number from the table and not generate a random one). I need some help here. I just cannot call the webpage directly using the controller without passing the room number.

I have tried passing the room number to the controller but doesn't seem to work and I am completely confused on how to execute it because of the way how php webpages work Any help would be appreciated.

1st - This is my view page for the patient where the ajax method checks if there's an entry and then opens the window for video chat


 $(document).on('click','#create_call', function(){

    var case_id=$(this).attr('class');
    $('#case_id_get').val(case_id);

    $.ajax({
            url: "<?php echo base_url('video/checkpatient');?>",
            type: "post",
            data: {case_id:case_id},
            success: function(response)
            {
                if(response==1)
                {
                    var newwindow = window.open('video/videochat');
                }
                else
                {
                    Messenger().post({
                        message: 'NO ENTRY FOUND',
                        type: 'error',
                        showCloseButton: true
                    });
                }
            }
        });


    });

video is my controller and checkpatient and videochat are its functions. Here's the controller within the functions


    public function videochat()
    {

            $views = array('video/webcam.php');
            $data = array('views'=>$views);
            $this->load->view('template/main',$data);
    }

    public function checkpatient()
    {
        $case_id = $this->input->post('case_id');
        $checkentry = $this->Call_Schedule->CheckPatientEntry($case_id);
        if($checkentry->num_rows()>0)
        {
            echo '1';
            exit;
        }
        echo '0';

    }

As you can see when I call videochat it opens a page named webcam.php which contains my script to start call.

<style>
    video {
  -webkit-transform: scaleX(-1);
  transform: scaleX(-1);
  }
  </style> 
  <div>
    <video id="localVideo" autoplay></video>
    <video id="remoteVideo" autoplay></video>
  </div>
<script>



hash = Math.floor(Math.random() * 0xFFFFFF).toString(16); 
const roomnumber = hash;
// Here I want the roomnumber to be used from the table not use the randomly generated number.

// other code to run the video call

How do I get the room number from the table corresponding to a patient/doctor?

  • 写回答

1条回答 默认 最新

  • dongmi5020 2019-06-14 07:55
    关注

    Here You Have passed echo '1' which is string but in response u have checked response == 1 which is int

    in controller

    public function checkpatient()
        {
            $case_id = $this->input->post('case_id');
            $checkentry = $this->Call_Schedule->CheckPatientEntry($case_id);
            if($checkentry->num_rows()>0)
            {
                echo '1';  // change to '1' to 1  string to int 
                exit;
            }
            echo '0';
    
        }
    

    In Script

    $.ajax({
                url: "<?php echo base_url('video/checkpatient');?>",
                type: "post",
                data: {case_id:case_id},
                success: function(response)
                {
                    if(parseInt(response)==1) // change from stringt  to  int 
                    {
                        var newwindow = window.open('video/videochat');
                    }
                    else
                    {
                        Messenger().post({
                            message: 'NO ENTRY FOUND',
                            type: 'error',
                            showCloseButton: true
                        });
                    }
                }
            });
    

    If this is not the cause please clarify that if case id is being printed in checkpatient() function or not

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?