Fetch Players Username With JQuery


Posted: 2018-01-20 17:19:14 |    Posted by iDev |    idevgames.co.uk

3
Login to like

By using ajax we can pull the username of the player of your game. Pulling the below url with ajax will give you the players username to use in your game or even website.

https://idev.games/request/user

Below is an example of auto populating an input field in jQuery.

<html>
<head>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
$.ajax({
 
url : 'https://idev.games/request/user',
type : 'GET',
dataType:'json',
error : function(request,error)
{
$( "#yourId" ).val(request['responseText']);
}
});
</script>
</head>
<body>
<form>
<input id="yourId">
</form>
</body>
</html>

 

Would you like to comment on this post? Create an account in less then 1 minute Click here



Back to top

Bump Reminder ChiefBuddy DISBOARD Dyno GameAddict gamerbread
11 Online Discord
·