How can i assign value of a javascript variable using php variable
$(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;
});
}
});
});
the code above works perfectly without php.Yet, i need to assign "var data" from mysql everytime.