problem with adding URL variable with JavaScript
I am trying to set and catch the URL variable
It begins with a form which has the standard action set to "/autorisation/logout" Then a button with an inline JavaScript function
function tbPayout()
{
parent.location = "/autorisation/logout?rcgo=payout";
return true;
}
<input src="/images/go02.gif" type=image border=0 name="go1" onClick="return tbPayout();">
In the authorization controller I try to catch it
if ( isset($_GET['rcgo']) ) {
but it doesn't work and I can't see the variable in the URL and therefore the default forms action is performed?
I also have another redirect page with:
content="3; url=http://www.domain.nl/index/index?rcgo=logout" />
and that works fine.
How can I get the JavaScript to work because I have three submit buttons that I need to control by using different URL variables that I need to read in the controller function. Which is logout() in this case.
It is worth m开发者_StackOverflow社区entioning that is has got something to do with the fact that it can not interpret the variable in the URI because it defaults to the index function off that controller which is the standard behavior if it can't find the second part. Without the variable attached, it redirects ok.
Is there a solution?
I think it's as simple as
parent.location.href = "/autorisation/logout?rcgo=payout";
instead of
parent.location = "/autorisation/logout?rcgo=payout";
Another option is using AJAX to pass as GET/POST directly...
var queryString = "?rcgo=payout";
ajaxRequest.open("POST", "/autorisation/logout" + queryString, true);
ajaxRequest.send(null);
精彩评论