I'm processing something and when the function is successful I would like to redirect to another page and there show the alert "Function successful".
I'm using CodeIgniter, Javascript and Bootstrap
Any ideas will be appreciated
I'm processing something and when the function is successful I would like to redirect to another page and there show the alert "Function successful".
I'm using CodeIgniter, Javascript and Bootstrap
Any ideas will be appreciated
Once page X has redirected to page Y, page X is no longer open, so can no longer issue alerts. Your options include:
iframe
; or, simply provide a link to it and let the user decide whether to click.)http://example.com/path/to/Y/?alert=Function+successful
, and you can design page Y to detect the query string and issue the alert.When the functions is successful, redirect and use the body onload event of the new page. Using a querystring extraction based on another SO answer:
if (success)
{
window.location("anotherpage.html?myparm=alertMe");
}
...
anotherpage.html
<body onload="bodyLoad();">
...
</body>
<script type="text/javascript">
function bodyLoad()
{
parmValue = getParameterByName("myparm");
if(parmValue == 'alertMe')
{
alert('Function successful');
}
}
//http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
</script>