CodeIgniter: redirect from embed view

Uroš Podkrižnik

I have a problem with redirection in embed view.

I'm, working on a project, where security is very important. I use codeigniter and bootstrap. I have main view, which includes navbar and some other html. In that main view i have <div id="change"> which i am changing via button group. With those buttons I am calling functions in controller with jQuery which (functions in controller) contains $this->load->view('pages/something', $data); When i press on one of those buttons <div id="change"> is changed and in it, a view is shown and link is not changed, so main view remains as it is.

<script>
var vari = "<?php echo $data['vari']; ?>";
$(function() {
    $("#btn1").click(function() {
        $("#change").load("Controller/function1/"+vari)
    })
    $("#btn2").click(function() {
        $("#change").load("Controller/function2/"+vari)
    })
    $("#btn3").click(function() {
        $("#change").load("Controller/function3/"+vari)
    })
    $("#btn4").click(function() {
        $("#change").load("Controller/function4/"+vari)
    })
    $("#btn5").click(function() {
        $("#change").load("Controller/function5/"+vari)
    })
})

When i do things in one of those embed views, sometimes i want to use redirect('/Controller', 'refresh');. Problem is, that when i use it, just embed view is changed - redirected, but main view with navbar and button group is still there.

How can i achieve, that when i call redirect() in "embed controller function", main view is changed, not only <div id="change">. Is this possible? If not with my method - what could be alternative solution, how can you redirect whole page from "embed controller function" (sorry i dont know how to name this =D).

I will appreciate any help. Thanks!

Johnny2k

If you want to redirect the user to another page you can use the following

var url = 'your/next/page';
$(location).attr('href',url);

without using jQuery you can also do

window.location.href = url;

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Redirect to View from AJAX call on error

분류에서Dev

Codeigniter: Redirect not working

분류에서Dev

Behaviour of redirect in codeigniter

분류에서Dev

How to pass select option array from ajax to codeigniter view?

분류에서Dev

Codeigniter redirect () 및 헤더

분류에서Dev

Mysql "CREATE VIEW" in Codeigniter

분류에서Dev

using $this in view file codeIgniter

분류에서Dev

Passing data to view Codeigniter

분류에서Dev

Embed a page from a PDF in HTML

분류에서Dev

How to pass parameters between two pages (from p:commandLink with redirect=true and view scoped beans)?

분류에서Dev

Codeigniter version 2.0.2 redirect loop issue

분류에서Dev

How to require a template view in the codeigniter?

분류에서Dev

Redirect to URL from CoffeeScript

분류에서Dev

Embed and execute native code from memory

분류에서Dev

Codeigniter Menu from Database

분류에서Dev

Codeigniter: load->view does not display page

분류에서Dev

display array values in view using codeigniter

분류에서Dev

Exclude folder from mobile redirect

분류에서Dev

.htaccess Redirect from URL with parameters

분류에서Dev

How to embed pens from CodePen into websites without CodePen frame

분류에서Dev

Create new brand from company: embed admin in admin in SonatAdminBundle

분류에서Dev

remove view from super view from otherclass

분류에서Dev

Codeigniter: What is the process behind data passing form controller to view?

분류에서Dev

Controller에서 View 로의 CodeIgniter 데이터

분류에서Dev

CodeIgniter - How to dynamically select a menu item in a partial view page for menu?

분류에서Dev

ingress nginx redirect from www to https

분류에서Dev

htaccess redirect links from multiple subdomains

분류에서Dev

Need to read Parameter from redirect in Flask

분류에서Dev

FOSUserBundle redirect from login page after logged in

Related 관련 기사

뜨겁다태그

보관