Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -

Post new topic Reply to topic  [ 1 post ] 
  Sat Oct 31, 2015 10:23 pm
User avatar

Omnipresent Merchant
Plugin Name: Simple Ajax
Version: 1
Author: Amy Pond @ http://www.hbgames.org


As RPG Maker MV games use JavaScript, one simple way to talk to a server is via the web, using Ajax. Technically here we aren't using the x part unless we format the responded text using XML, but the principle is the same.

This plugin is one simple function that returns a text variable from a web server using some entered variables.

How to Use

Create a PHP file on your web server which returns a text response (using echo() for example). Use GET variables to generate the response based on data sent to it.

There is an example PHP file in the Help part of the plugin.

Install the plugin, and type in the location of your PHP file, for example: http://www.rpgmakerweb.com/files/ajax.php (not a real file).

As an example of its usage:

var mytext = ajaxRequest("variable=1&othervariable=2");

On the server we check for $_GET['variable'] and $_GET['othervariable'].

We clean the variables before using (this is very important - please read up on cleaning user sent data in PHP).

Then we do something with these variables and send back some data. Say we echo("hello"), then:

var mytext = ajaxRequest("variable=1&othervariable=2"); // mytext = "hello"

Expand to see the code.


By Amy and originally created for the game Afar.

Thanks to w3schools.

Terms of Use

Free for use in any game with no credit necessary. If you like you can provide a link to HBGames.org or this thread but this is not necessary. Available for commercial games for free.

Please note that this script used incorrectly creates a vulnerable web server. If you do not clean your GET variables then you ARE open to hacking quite easily. No liability is accepted for any damage caused by use of this function. Use is at your own risk and I urge you to look into PHP security, in particular, cleaning data sent from a user. For integers this can be as simple as turning them into integer variables by (int)var, though for text you will need prewritten functions, or to make your own using preg_replace.

Top Top
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

Who is online

Users browsing this forum: No users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group