Reputation: 304
I am Using redirect function of Codeigniter with alert of JavaScript. I want to display message first before redirect to other page, but my code just directly redirect the page without displaying alert message. I need code in method of controller of codeigniter.I used code as follows in method of controller:
echo "<script type='text/javascript'>alert('Duplicate Users')</script>";
redirect('auth/login'),'location');
Plz Advice me Waiting for Response Thank You very Much for supporting me.
Upvotes: 0
Views: 11540
Reputation: 1159
See this ..
Server code (PHP -> redirect)
is fired up before Client Code (JS -> alert)
. There are several solutions to this but the easiest one is to use one type of code for the functionality (either PHP or JS) ..
Let's use PHP to fire up JS for now, since that's what you're using ..
echo "<script>alert('Duplicate Users') ; window.location.href = 'auth/login'</script>"
Upvotes: 1
Reputation: 1246
<script>
alert("Duplicate Users");
window.location.href = "auth/login";
</script>
Upvotes: 0