title: assign php variable to javascript variable
body: <p>How can i assign value of a javascript variable using php variable</p>
  
  <pre><code> $(function(){
      $("select[name=myselectlist]").change(function(){
          var id = $(this).val();
          if(id != 0) {       
              $.post("ajax.php", {"id":id}, function(){
                  var data = "somedatahere";
                  document.getElementById("namesurname").value = data;
              });
          }
      });
  });
  </code></pre>
  
  <p>the code above works perfectly without php.Yet, i need to assign "var data" from mysql everytime.</p>