user2350138 user2350138 - 3 months ago 12x
jQuery Question

Uncaught Reference Error : <<some value >> not defined Jquery

I know this issue is faced by many pupil. I am not sure what's issue in the code. Although i properly ordered my script tag i got the following issue.

I need to send a value from one PHP file to other PHP. Which inturn used in js. Below is the code.


<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="../../bootstrap/css/bootstrap.css" rel="stylesheet" >
<script src=""></script>
<script src="../../bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#container').load('delete2.php?os=' + 'myos');

<title>Cognizant's Asset Tracker</title>

<div id = "container" style = "min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>


$test = $_GET['os'];
echo $test;
<script type="text/javascript">
$(document).ready(function () {
var jstest = <?php echo $test; ?>;

When i executed i got the below output.
enter image description here

I am using bootstrap 3.3.6.
Appreciate your support.


You have to quote the printed string or it gets printed as a variable name and that undefined variable is throwing the error shown

var jstest = '<?php echo $test; ?>';