0

I have a Bootstrap modal login form. I want to perform AJAX form validation where I want to display the errors using AJAX. All of this is working perfectly but I want the form to redirect to some other view along with some data on successful login.

But here the problem is that I cannot do $('html').html(data); as it is although returning the required thing but with different font and without models and few other features.

Everything is working fine when I do the validation without AJAX but in that case, the error does not appear directly, one has to again toggle the model to view the errors.

So overall I just want to use AJAX for displaying the errors but if the error is not there I just want to display the result directly through CodeIgniter as if there was no AJAX Request.

tereško
  • 58,060
  • 25
  • 98
  • 150
pokemon
  • 71
  • 1
  • 12

1 Answers1

1

You should replace the HTML but simple change the window location. In your success, add this line:

$.ajax({
    /*...*/
    success: function(data){
        window.location.href = "index.php/YourNewPage";
    }
    /*...*/
})

Make sure your other page is register in your route.php as well, so you can acces it via url.

Nicolas
  • 8,077
  • 4
  • 21
  • 51