Variable data in ajax call JQUERY

Viewed 41627

I'm trying to use variable in AJAX call in jquery but it is not working. move variable contains different values. Please check the following code:

var $move = 'next';

$.ajax({
   type: "POST",
   url: "somephp.php",
   data: {$move:1},
});

Suggest any way to use $move variable in data.

7 Answers

I was looking for something like this. I wanted to have a variable for the key AND a variable for the value.

let dataPair = {};
dataPair[dataKey] = dataValue;
$.ajax({
  url: TheAPIPath,
  data: dataPair,
  method: "GET",
(etc)
Related