Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  189] [ 6]  / answers: 1 / hits: 24268  / 11 Years ago, wed, july 31, 2013, 12:00:00

I need to update the session variable on page 1, when click on a link in iframe (external page).
session variable is successfully set when i click on iframe's link.
the problem is i need to refresh the page 1 to update that session variable on page1.



enter



how to resolve this.any ajax , jquery help.
THanks


More From » php

 Answers
41

HTML a href link:



<a href=# id=clickme>Update Session</a>


jQuery codes:



You can send data with line of data: { varname: 'here we go'}



<script src=http://code.jquery.com/jquery-1.10.1.min.js></script>
<script>
$(#clickme).click(function(e) {
e.preventDefault();
$.ajax({
type:'POST',
url:'update.php',
data: { varname: 'here we go'},
success:function(response){
alert(response);
}
});
});
</script>


update.php file:



You can get sent var with $_POST[varname]



<?php
$_SESSION[varname] = $_POST[varname];
echo $_SESSION[varname];
?>

[#76635] Tuesday, July 30, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leslijessalyng

Total Points: 650
Total Questions: 85
Total Answers: 109

Location: Croatia
Member since Mon, Sep 6, 2021
3 Years ago
leslijessalyng questions
Fri, Feb 21, 20, 00:00, 4 Years ago
Tue, Jul 30, 19, 00:00, 5 Years ago
Fri, Jul 5, 19, 00:00, 5 Years ago
Wed, Mar 13, 19, 00:00, 5 Years ago
;