play.idevgames.co.uk
   170 GAMES
   425 MEMBERS
   16 TUTORIALS
   53 DEV LOGS
Forgot your password? Click here
Back

Fetch Players Username With JQuery


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


2
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.php

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

Nobody has commented on this post yet.

Back to top