CodeIgniter Forums
newbie redirect question with ajax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: newbie redirect question with ajax (/showthread.php?tid=60120)



newbie redirect question with ajax - El Forum - 01-19-2014

[eluser]gloosemo[/eluser]
i'm trying to redirect from within a controller to a different page, recinput2.

redirect('recinput2', 'location');

when i run this in a controller function called login that is called via ajax, i get the response in ajax and i can view the page in firebug but the page itself does not change in the browser. How can i get the webpage to change in the browser in response to an ajax call?

BTW The ajax call is made with jQuery

Code:
var username = $('#username').val();
  var password = $('#password').val();
  //clog(username);
  //clog(password);
  
  function logObj ( a, b ) {
   this.username = a;
   this.password = b;
  }
  var obj = new logObj ( username, password );
  var strToSend = encodeURIComponent(jQuery.toJSON( obj ));

  $.ajax({
   url: '/index.php/welcome/login',
   type: 'POST',
   async: false,
   data: 'passme=' + strToSend,
   success: function(data) {  
    /*
    alert("Receipt Deleted");
    oTable.fnReloadAjax();
    */
   }
  });



newbie redirect question with ajax - El Forum - 01-19-2014

[eluser]CroNiX[/eluser]
Code:
success: function(data) {  
  [removed] = 'http://www.yoursite.com/the/url';  //force the browser to go to the new url  
}

Edit: The forum filters it out.

it's window[dot]location = the url
http://www.tizag.com/javascriptT/javascriptredirect.php