title: AJAX call is failing with ReferenceError assignment to undeclared variable PostRPC
body: <p>I'm trying to open a modal using dynamic data from database with AJAX function. But when I click on the button to open modal I get</p>
  
  <blockquote>
    <p>ReferenceError: assignment to undeclared variable PostRPC in category.php on line 3 col 2.</p>
  </blockquote>
  
  <p>EDIT</p>
  
  <p>Reading <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undeclared_var" rel="nofollow noreferrer">Firefox document</a> I understand this error type is because a value has been assigned to an undeclared variable. In other words, there was an assignment without the var keyword. There are some differences between declared and undeclared variables, which might lead to unexpected results and that's why JavaScript presents an error in strict mode. I'm trying to find where there's an undeclared variable in my code which is strange.</p>
  
  <p>category.php</p>
  
  <pre><code>        &lt;!DOCTYPE html&gt;
          &lt;html lang="en"&gt;
          &lt;head&gt;
          &lt;script src="js/jquery.js"&gt;&lt;/script&gt;
                     &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;
              &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
  
               &lt;script src="js/jquery-migrate-1.2.1.js"&gt;&lt;/script&gt;
                    &lt;!-- Latest compiled and minified JavaScript --&gt;
          &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;&lt;/script&gt;
  
               &lt;script src="js/script.js"&gt;&lt;/script&gt; 
               &lt;script src="js/superfish.js"&gt;&lt;/script&gt;
               &lt;script src="js/jquery.ui.totop.js"&gt;&lt;/script&gt;
               &lt;script src="js/jquery.equalheights.js"&gt;&lt;/script&gt;
               &lt;script src="js/jquery.mobilemenu.js"&gt;&lt;/script&gt;
               &lt;script src="js/jquery.easing.1.3.js"&gt;&lt;/script&gt;
                &lt;script src="js/jquery.tooltipster.js"&gt;&lt;/script&gt;
               &lt;script&gt;
                 $(document).ready(function(){
                  $().UItoTop({ easingType: 'easeOutQuart' });
                  $('.tooltip').tooltipster();
                  });
               &lt;/script&gt;
               &lt;script&gt;
               $(function(){
                  $('#pull').on('click', function(e) {
                          e.preventDefault();
                          $('#menu').slideToggle();
                      });
  
              })
               &lt;/script&gt;
               &lt;/head&gt;
  
      &lt;body&gt;
  
  &lt;?php $sql = "SELECT * FROM product WHERE featured = 1";
  $featured = $db-&gt;query($sql);
  ?&gt;
  
        &lt;?php while($product = mysqli_fetch_assoc($featured)) : ?&gt;
          &lt;div class="grid_4"&gt;
          &lt;a href="#"&gt;  &lt;img src="images/page2_img1.jpg" alt=""&gt;&lt;/a&gt;
            &lt;div class="text1"&gt;&lt;a href="#"&gt;Product Name&lt;/a&gt;&lt;/div&gt;
            &lt;a href="#"&gt;   120.00$ &lt;/a&gt;
            &lt;div class="alright"&gt;&lt;button type="button" class="btn btn-sm btn-success" onclick="detailsmodal(&lt;?php echo $product['id']; ?&gt;)"&gt;See Product&lt;/button&gt;&lt;/div&gt;
          &lt;/div&gt;
              &lt;?php        endwhile; ?&gt;
  
  &lt;!--==============================footer=================================--&gt;
  &lt;?php include'/includes/footer.php'?&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>footer.php</p>
  
  <pre><code>    &lt;script src="js/classie.js"&gt;&lt;/script&gt;
  
      &lt;script src="js/thumbnailGridEffects.js"&gt;&lt;/script&gt;
      &lt;script&gt;
  $(document).ready(function detailsmodal(id){
   var data = {"id" :  id};
   jQuery.ajax({
       url : "&lt;?php echo BASEURL;?&gt;+ '/MyProjectName/includes/detailsmodal.php",
       method  : "post",
       data : data,
       success : function(data){
           jQuery('body').append(data);
           jQuery('#details-modal').modal('toggle');
       },
       error : function(){
           alert("Something went wrong!");
       }
   });
  
  };
      &lt;/script&gt;
  </code></pre>