Reputation: 113
I'm trying to get game server data from my other host because my main host doesn't allow server querying. But i'm having problems with json right now..
My code:
<script type='text/javascript'>
$(document).ready(function(){
$("input.senddata").click(function() {
var ipForm = $('input[name="ip_submit"]').val();
var gameForm = $( 'select[name="game_submit"]' ).val()
$.getJSON("http://gamepwn.net/serversdotee/add-server.php?json=true",
{
ip: ipForm,
game: gameForm
},
function(data) {
$('.result').html(data);
});
});
});
</script>
The data that i want to get back is a simple text for example "Server has been queried"..
Upvotes: 0
Views: 935
Reputation: 95062
Either your "other server" needs to return proper CORS headers, or you need to move to the JSONP
datatype and modify your "other server" so that it properly returns JSONP
rather than JSON
.
JSONP vs JSON:
JSON: http://gamepwn.net/serversdotee/add-server.php?json=true
{"foo":"bar"}
JSONP: http://gamepwn.net/serversdotee/add-server.php?json=true&callback=??
jQuery_7891469862340189270349182561({"foo":"bar"})
Where jQuery_7891469862340189270349182561
is the value of the callback GET parameter.
Upvotes: 2