Welcome Guest, Not a member yet? Register   Sign In
CI4 Views and Ajax
#3

Thanks so much for that InsiteFX.

I have got the example working, It took a bit to get it working in CI4.

loading the model the CI4 way
SQL needed builder to replace the old sql
CSRF handling tokens with the ajax queries
isset using $_POST['username']

I have one little thing to solve with refreshing the CSRF token before I start disecting this and understanding it. (i get once use before a 403 lol)









I am still not sure if this is what I am trying to do though.

I have several views view1, view2 view3
When i load view1, on the page is a button to load view2. Instead of refreshing the page, I want to replace the contents of view1 with the contents of view2 if that makes any sense

view1.php

<?= $this->extend($config->viewLayout) ?>
<?= $this->section('main') ?>
<div class="container view1" >
This is view 1
<div>


<?= $this->endSection() ?>


view2.php

<?= $this->extend($config->viewLayout) ?>
<?= $this->section('main') ?>
<div class="container view2" >
This is view 2
<div>


<?= $this->endSection() ?>

views are loaded in from layout.php

<main role="main" class="wrapper">
<?= $this->renderSection('main') ?>
</main>

typically these are loaded in by the controllers
controller1.php
public function view1()
{
return view($this->config->views['view1'], [
'userData' => $this->session->userData
]);
}

controller2.php
public function view2()
{
return view($this->config->views['view2'], [
'userData' => $this->session->userData
]);
}

Is AJAX going to help me load in these views? Smile
Reply


Messages In This Thread
CI4 Views and Ajax - by kristianlake - 06-14-2020, 01:26 PM
RE: CI4 Views and Ajax - by InsiteFX - 06-15-2020, 02:49 AM
RE: CI4 Views and Ajax - by kristianlake - 06-15-2020, 02:16 PM
RE: CI4 Views and Ajax - by InsiteFX - 06-16-2020, 03:32 AM
RE: CI4 Views and Ajax - by kristianlake - 06-16-2020, 01:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB