jQuery passing parameters with .load
Fill a div with data returned from a jQuery POST. An alert on the client side displays the arriving data.
Who is calling. This data is being passed via POST.
...
<body><div class="spec" id="spec" ></div></body>
...
<script>$("#spec").load("generic.php", {link:"12345679"});</script>
Who is called: (generic.php)
<?php
function GetXParameter()
{
$path = $_POST['link'];
return urldecode($path);
}
$p = GetXParameter();
?>
<html>
<head><script src="../../js/jquery-3.3.1.min.js"></script></head>
<body>
<div id='caption'>This is the shit. '<? echo $p; ?>'</div>
<script>
$(document).ready(function ()
{ alert ('link = ' + '<? echo $p; ?>'); });
</script>
</body>
</html>
Leave a Reply