I am using JavaScript to pass a variable to another php file. I have a value in javascript, and I want to pass it as a post variable to another php file.
Javascript code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" >
//Important code here to post a variable to bh.php:
$(document).ready(function(){
$('#op_comp_id').load('bh.php').show();
$('#get_value_id').keyup(function() {
$.post('bh.php', { id: form.get_value.value },
function(result){
$('#op_comp_id').html(result).show();
});
});
});
</script>
</head>
<body>
<?$id = $_GET['id'];?>
<form name="form">
<input type="text" id="get_value_id" name="get_value" value="<?php echo $id ?>">
</input>
</form>
<div id="op_comp_id"></div>
</body>
</html>
This was my attempt to pass a variable value from javascript to bh.php
in post mode.
bh.php?id=value
Is there an alternative way or better way to do this?