php pass a variabele to js
<script>
'var name = <?php echo json_encode($name); ?>;
</script>'
php pass a variabele to js
<script>
'var name = <?php echo json_encode($name); ?>;
</script>'
how to use jquery variable in php
Try this one:
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
var id = 23;
$("#submit").click(function(){
$.ajax(
{
url: "B.php",
type: "POST",
data: { id1: id},
success: function (result) {
alert('success');
}
});
});
});
</script>
</head>
<body>
<form >
<input type="button" id="submit" name="submit"/>
</form>
</body>
</html>
Then B.php
<?php
$a =isset($_POST['id1'])?$_POST['id1']:'not yet';
echo $a ;
?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us