estoy tratando de hacer un separados de user agent string a través de ajax y php pero a la hora de hacer el code de ajax me aparece el siguiente aviso en la consola
jQuery.Deferred exception: Cannot access 'get_overs' before initialization ReferenceError: Cannot access 'get_overs' before initialization at HTMLDocument. (http://127.0.0.1/fumado/:208:19) at e (https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js:2:30005) at t (https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js:2:30307) undefined
Ajax:
<script>
$(document).ready(function () {
const get_overs = <?php $get_over = $_SERVER['HTTP_USER_AGENT'];?>
$.ajax({
type: "POST",
url: "./assets/php/locate.php",
data: { get_over: get_overs }
}).done(function( msg ) {
console.log( "Los datos que se recibieron: " + msg );
});
});
</script>
Php (inicio de pág):
<?php
$get_over = $_SERVER['HTTP_USER_AGENT'];
?>
locate.php:
<?php
$get_over = $_POST['get_overs'];
$separar = explode("Mozilla/5.0",$get_over);
$allow = array("Windows"); //dominios válidos
$dom = $separar[1];
if(in_array($dom,$allow)){
print 'allowed';
}else{
print 'wtf';
}
?>
const get_overs = <?php $get_over = $_SERVER['HTTP_USER_AGENT'];?>