So I got a quick script working with HTML and JS, but I can’t for the love of me get the response from the POST request. Here is what I have currently have:
<!DOCTYPE html>
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="something()">Click Me!</button>
<script>
function something(){
const Url = 'https://somelink.com';
const date = 'somedata'
var V
$.post(Url,date,function(data) {
V = data
});
alert(V)
}
</script>
</body>
</html>
I did try having the alert in the function(data) part but it would not register for some exact reason so I moved it out. Now it registers the alert but it can not get the response from the request.
I am testing it in JS Fiddle and the console log is “50:9 Uncaught ReferenceError: V is not defined”. Any and all help/nudges will be greatly appreciated. My goal is to get the response from the request and use it further down the line, so I am just testing as a proof of concept/correct coding with the alert.