how to use variable in AJAX => data:
by pizzipie from LinuxQuestions.org on (#5MEV5)
Using Ubuntu 20.04
Code: $("#doctor").focus(function(){
alert("focus is on #doctor");
indata="doctor";
})
var request = $.ajax({
url: "dropList.v_final.php",
type: "POST",
data: {"doc":indata},
dataType: "json"
});I cannot get this AJAX call to pass the data to the URL. print_r($_POST) shows an empty array.
If I use data: {"doc":"doctor"} print_r($_POST) shows [doc] doctor as it should.
I have tried various combinations with quotes but no joy.
Code: $("#doctor").focus(function(){
alert("focus is on #doctor");
indata="doctor";
})
var request = $.ajax({
url: "dropList.v_final.php",
type: "POST",
data: {"doc":indata},
dataType: "json"
});I cannot get this AJAX call to pass the data to the URL. print_r($_POST) shows an empty array.
If I use data: {"doc":"doctor"} print_r($_POST) shows [doc] doctor as it should.
I have tried various combinations with quotes but no joy.