In my main.php file in the main root i'm using:
$isWebView = false;
if((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false)) :
$isWebView = true;
elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH'])) :
$isWebView = true;
endif;
echo json_encode($isWebView);
to check if is webview or browser and i save result as a boolean in the $isWebView var.
now i'm trying to load that result in my main.js file inside scripts folder like below but it doesn't work, why? i get error data is not defined.
$.ajax({
url: 'main.php',
type: 'POST',
dataType: 'json',
data: data,
success: function(data){
console.log(data);
}
});