Basically, I have a jQuery script which detects when a certain button is pressed. When the button is pressed, the script is meant to make a GET request to a separate PHP file. The PHP file should return a string to the JavaScript file, but I have multiple errors in both my scripts, creating a problem.
<script type="text/javascript">
$(document).ready(function() {
$('#generate').click(function(){
$.get("give.php?data").done(function(info){
console.log(info);
});
});
});
</script>
When logging info, I get nothing. Literally, nothing.
<?php
$f_contents = file("combo.txt");
$line = $f_contents[array_rand($f_contents)];
$data = $line;
$_GET['data']
?>
That's my PHP script.
If someone can help me out, I would appreciate it. None of the posts on the internet helped me out.
Thanks!
Oh and yes, I know my code is terrible.
Network Tab
question from:
https://stackoverflow.com/questions/65872973/getting-a-string-from-php-using-jquery 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…