As a beginner in post requests, I've been encountering an error when attempting to make a post request. Despite searching for solutions, the answers are too complex for me to grasp how to adjust my code to resolve it.
var url = 'http://unturnedbox.clanservers.com/serverquery/serverQuery.php';
$(document).on('click','.test', function(getServerInfo)
{
var getServerInfo =
{
"ip": "23.229.5.250",
"port": "27021"
}
$.post(url, JSON.stringify(getServerInfo), function(response)
{
response.addHeader("Access-Control-Allow-Origin", "http://unturnedbox.clanservers.com");
if (response.error)
{
}
else
{
$('.test').html('<div>'+ response.result.length +'</div>');
}
});
});
I would greatly appreciate it if someone could explain what mistakes I may be making. Thank you.