I'm trying to pass a php variable from page1.html (which contains a php variable that I got from another form) to page2.php using ajax but it's not working, so I need your help.
code from page1.php:
<script>
var url = 'page2.php';
$("#save").click( function() {
$.ajax({
url : url,
type: 'post',
data : {
admin : <?php echo $admin; ?>,
gname : <?php echo $gname; ?>,
filename : docname,
content : encodeURIComponent(editor.getValue())
}
});
});
</script>
The datas filename and content are being sent successfully but admin and gname are not.
Thanks in advance.
UPDATE:
<?php
if(isset($_GET['admin'])) {
$admin = $_GET['admin'];
}
if(isset($_GET['gname'])) {
$gname = $_GET['gname'];
}
?>
This code is where I get the php variable that I want to send, from another form which is irrelevant to this question.