I am new to javascript and query. This is my first attempt on it.
My code is pretty simple as follows:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#get").click(function() {
$.ajax( {
url: "get_port.php",
type: "GET",
success: function(result) {
console.log(result);
},
error: function(data) {
console.log(data)
}
});
});
});
</script>
<style>
.button {
background-color: #4CAF50;
color: #fff;
cursor: pointer;
border: none;
color: white;
padding: 15px 25px;
border-radius: 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 24px;
box-shadow: 0 5px #999;
}
.button:hover {
background-color: #3E8E41;
}
.button:active {
background-color: #3E8E41;
box-shadow: 0 1px #666;
transform: translateY(4px);
}
</style>
</head>
<body>
<div align="center">
<form>
<p style="font-size: 30px;">Current Port: 
<span id="port_name"
style="font-size: 30px;">Unknown
</span>
</p>
<button class="button" id="get">Get</button>
</form>
</div>
</body>
</html>
My php code:
<?php
$ss_json = file_get_contents("/etc/shadowsocks.json");
$ss_config = json_decode($ss_json, true);
foreach($ss_config['port_password'] as $key => $value) {
echo $key;
}
?>
And I get no response from my php file with status code 0. My php is just a simple echo sentence. The return type is also not json. Someone please figure this out for me!!
I have been working on it for an entire day and I have literally no clue for solving this problem.
My error message:
{readyState: 0, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function, …}
Also I have checked the access log and it shows the following log:
"GET /get_port.php HTTP/1.1" 200 199"