Welcome Guest, Not a member yet? Register   Sign In
Auto refresh particular div using jquery or AJAX

Hi everyone,

i'm a beginner in using the codeigniter and i have a question on how to refresh particular div using jquery or ajax. i've tried to search and try to fix it but it is not working.

this is my view page:
function test(){
            $('#jobs').html("<?php $this->load->view('jobs_page.php'); ?>");
        setInterval( "test()", 1000 );

this is the div that needs to be auto updated
<div id="jobs" class="middle_row">
        &lt;? $this->load->view('jobs_page.php'); ?&gt;

this is the jobs_page.php
<table border="1" width="100%" bgcolor="transparent">
                        <td width="10px">No.</td>
                        <td width="70px">Project %</td>
                        $result = $jobs;
                        foreach($result as $row)
                        <td>&lt;? echo $row->id; ?&gt;</td>
                        <td>&lt;? echo $row->prj_name; ?&gt;</td>
                        <td>&lt;? echo $row->status; ?&gt;</td>
                        <td>&lt;? echo $row->progress; ?&gt;</td>
                        <td>&lt;? echo $row->prj_percent; ?&gt;</td>
                        <td>&lt;? echo $row->deadline; ?&gt;</td>
                        <td>&lt;input type="text" id="tester"&gt;&lt;/td>
                    &lt;?  } ?&gt;

any help regarding this is highly appreciated. Thank you before.

Javascript runs in the clients browser. It doesn't know php.

Use ajax to periodically send a request to the server via POST. In the controller/method that the ajax request is calling, return the desired view. Then, in the success event of the ajax call, show the returned HTML in your div.

Theme © iAndrew 2016 - Forum software by © MyBB