Article 5MEV5 how to use variable in AJAX => data:

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.latest?d=yIl2AUoC8zA latest?i=EatuudWFkXA:pYyxUu7oyTo:F7zBnMy latest?i=EatuudWFkXA:pYyxUu7oyTo:V_sGLiP latest?d=qj6IDK7rITs latest?i=EatuudWFkXA:pYyxUu7oyTo:gIN9vFwEatuudWFkXA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments