350 GAMES
   801 MEMBERS
   20 TUTORIALS
   97 DEV LOGS
Forgot your password? Click here


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://play.idevgames.co.uk/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://play.idevgames.co.uk/request/user.php',
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