javascript.
#5

We use javascript and php simultaneously for that.
****** the term "ajax and php".
I prefer passing information in form form of json object, so here is a short example of how to do it :

First lets create the php file to get server info which outputs it in form of json.
PHP код:
//get_info.php
<?php
require("SampQueryAPI.php");
$query = new SampQueryAPI('127.0.0.1''7777');//change ip and port here
if(!$query->isOnline())
{
    echo 
"Server Offline";
    exit();
}
$info $query->getInfo();
echo 
json_encode($info);
?>
Now to get info from php file into javascript we use ajax( note that you need jquery for it)
PHP код:
//javascript
$.ajax({
            
url"get_info.php"
       
}).done(function(data)
       {
            var 
info JSON.parse(data);
            
//now use info.players , info.maxplayers , info.hostname.... etc
            
alert("Game mode of server is : "+info.gamemode);
       } 
Reply


Messages In This Thread
javascript. - by Banditukas - 02.04.2015, 14:38
Re: javascript. - by Banditukas - 03.04.2015, 10:21
Re: javascript. - by BroZeus - 04.04.2015, 05:36
Re: javascript. - by Banditukas - 04.04.2015, 06:38
Re: javascript. - by BroZeus - 04.04.2015, 10:41
Re: javascript. - by Banditukas - 04.04.2015, 11:03
Re: javascript. - by BroZeus - 04.04.2015, 11:08
Re: javascript. - by Banditukas - 04.04.2015, 12:30
Re: javascript. - by BroZeus - 04.04.2015, 15:19
Re: javascript. - by Banditukas - 04.04.2015, 17:00

Forum Jump:


Users browsing this thread: 2 Guest(s)