Reputation: 49
When I go to this link : http://main.php?valretour=OK
, how can I get the value of valretour
?
Main.php
I tried this directly in my PHP page...:
<script>
alert($_GET['valretour']);
if($_GET['valretour'] == "OK"){
$.toaster({ priority : 'success', title : 'Success', message : 'OK' });
} else {
$.toaster({ priority : 'warning', title : 'Failed', message : 'NOT' });
}
</script>
My page main.php
<html>
<head>
<!--Links css-->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script type='text/javascript' src='jquery/external/jquery/jquery.js'></script>
<script type='text/javascript' src="jquery/jquery-ui.js"></script>
<script src="jquery/jquery.toaster.js"></script>
</head>
<body>
<div id="logo">
<a href="#"><img src="images/logost.png" style="width:180px;height:120px"></a>
</div>
<script src="jquery/external/jquery/jquery.js"></script>
<script src="jquery/jquery-ui.js"></script>
<script>
alert($_GET['valretour']);
if($_GET['valretour'] == "OK"){
$.toaster({ priority : 'success', title : 'Success', message : 'OK' });
} else {
$.toaster({ priority : 'warning', title : 'Failed', message : 'NOT' });
}
alert();
</script>
</body>
</html>
Upvotes: 0
Views: 34
Reputation: 66488
You need to parse location.search
:
var query = (function() {
function decode(string) {
return decodeURIComponent(string.replace(/\+/g, " "));
}
var result = {};
if (location.search) {
location.search.substring(1).split('&').forEach(function(pair) {
pair = pair.split('=');
result[decode(pair[0])] = decode(pair[1]);
});
}
return result;
})();
if(query['valretour'] == "OK"){
$.toaster({ priority : 'success', title : 'Success', message : 'OK' });
} else {
$.toaster({ priority : 'warning', title : 'Failed', message : 'NOT' });
}
Upvotes: 1