I am busy making a web application, which needs to process a lot of erorrs and stuff so i made a jquery ui dialog box. Which shows these errors. The errors are retrieved by database. for example:
when my username/password is incorrect when i try to log in i get redirected to
http://domain.com/?do=login&e=login-incorrect
the application then know he has to search for the login-incorrect error in the database and show that to the user. Now this all goes very well. Except that when for some reason the user would reload this particular page he wel get the error message again while he doesnt need to get it.
so my plan is to bind some kind of function to the close
event of the dialog box and redirect the user to the same page bug without the e parameter in the URL. How could i achieve this. I tried all sorts of stuff. But could not get it to work.
What i tried:
bassicly tried getting all possible parameters and stitching those together except for the e parameter. like so:
$ERROR = $_GET['e'];
$DO = $_GET['do'];
$P = $_GET['p'];
$C = $_GET['c'];
$T = $_GET['t'];
$ACTION = $_GET['action'];
// URL WITHOUT ERRORS
$needP = "";
$needACTION = "";
$needDO = "";
if($P != ""){
$needP = "p=".$P."&";
}
if($DO != ""){
$needDO = "do=".$DO."&";
}
if($ACTION != ""){
$needACTION = "action=".$ACTION."";
}
$NOERRORURL = $BASEURL."?".$needP.$needDO.$needACTION;
But it does not work and its ugly
Just pass in the param you want to remove from the URL and the original URL value, and the function will strip it out for you. To use it, simply do something like this: var originalURL = "http://yourewebsite.com?id=10&color_id=1"; var alteredURL = removeParam("color_id", originalURL);
To remove a querystring from a url, use the split() method to split the string on a question mark and access the array element at index 0 , e.g. url. split('? ')[0] . The split method will return an array containing 2 substrings, where the first element is the url before the querystring.
location.href=location.href.replace(/&?e=([^&]$|[^&]*)/i, "");
This will remove all instances of the e parameter from the query string and refresh the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With