Pass data to another page
- by user2331416
I am trying to pass some data from one page to another page by using jquery but it dose not working, below is the code which I want to click the text in source page and the destination page will hide the current text.
Source page:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("a.pass").bind("click", function () {
var url = "Destination.html?name=" + encodeURIComponent($("a.pass").text());
window.location.href = url;
});
});
</script>
</head>
<body>
<a class="pass">a</a><br />
<a class="pass">b</a><br />
<a class="pass">c</a><br />
<a class="pass">d</a>
</body>
</html>
Destination page:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var queryString = new Array();
$(function () {
if (queryString.length == 0) {
if (window.location.search.split('?').length > 1) {
var params = window.location.search.split('?')[1].split('&');
for (var i = 0; i < params.length; i++) {
var key = params[i].split('=')[0];
var value = decodeURIComponent(params[i].split('=')[1]);
queryString[key] = value;
}
}
}
if (queryString["name"] != null) {
var data = queryString["name"]
$("p.+'data'").hide();
}
});
</script>
</head>
<body>
<p class="a">a</p>
<p class="b">b</p>
<p class="c">c</p>
<p class="d">d</p>
</body>
</html>
Please Help.