So I'm trying to achieve the following, but I can't figure out how to make this work.
$.ajax({
url: "whatever.php",
method: "POST",
data: { myVar: "hello" },
success: function(response) {
console.log('received this response: '+response);
console.log('the value of myVar was: '+data.myVar); // <<<< data.myVar is not accessible from here
console.log('the value of myVar was: '+myVar); // <<<< myVar is not accessible from here
}
});
Is there a way to access the value of myVar
in the .success()
function?
Can I somehow get to the original data
object that was sent in this ajax request, in the .success()
function?
Hoping for your solutions. Thanks!