I'm trying to make an API call to a Minecraft api that returns, along others, a status message, and then print it out on the site. For that I'm using an AJAX JSON call, getting the entered string to connect to the API and to GET the information about the server in a function (which I'm pretty sure is the most common way to do that).
However, when I try and enter a (working) IP, it displays the researching data... message very briefly and then clears the field again. Nothing appears, even though there should be a status massage from the API. It doesn't even log in the console.
Any help on that?
JS Code:
function getStatus(){
var ip = $("#ip").val(); //getting the value from the textbox
if(ip == ""){
$("#addmes").html("<h1>you didn't enter anything -.-</h1>"); //checking if anything is entered
} else {
$("#addmes").html("<h1>researching data...</h1>"); //displaying a temporary status message
$.getJSON("http://api.syfaro.net/minecraft/1.2/server/status?ip="+ ip + "&callback=?", function(json){ //connecting to the API, using the IP variable in the process
console.log(json); //console log
$("#addmes").html("<h1>" + json[0].status + "</h1>"); //printing out the API status message
})
}
}
API response (tested with http://api.syfaro.net/minecraft/1.2/server/status?ip=mc.hypixel.net&callback=?):
?({"status":"success","ip":"mc.hypixel.net","port":25565,"last_update":"2013-12-19 09:09:58","online":true,"motd":"\u00a7aHypixel Lobby \u00a76| \u00a7cPlay Now! \u00a7eMega Walls \u00a7aPublic BETA!","players":{"max":16001,"online":6989,"list":false},"version":"1.7.2","favicon":false});
?to&callback=?help?&callback=??what version of jquery is this