Download .zip |
Info | Example | View files (7) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2015-11-15 (3 years ago) | Not enough user ratings | Total: 100 | All time: 406 This week: 9 |
Version | License | JavaScript version | Categories | |||
parameters-transmit 1.1 | MIT/X Consortium ... | 1.2 | AJAX, Forms |
Description | Author | |||
This object can send form parameter data via AJAX PUT or POST. Innovation Award
|
The communication between JavaScript client-side (hereinafter JS) and PHP server-side, for example, requires the two-way exchange of the parameters. You need to solve the following tasks to coordinate the activity on both sides:
There are many different solutions for that and ParmTran JavaScript class is one of them. This class supplies necessary front-end methods but assumes according support from the back-end.
The back-end prepares and encodes the storage data, and places the data inside the HTML to be sent to the front-end. JS accepts the data and saves it into the storage. The storage data is accessed by the Get/Set methods and used internally.
JS makes requests via GET/POST where AJAX request sends the JSON string in the request body. The back-end detects the request format and saves the parameters. The AJAX response is returned with the array in specific format (see below).
The ParmTran can be complemented with more methods and properties. So, it can be a template for your own framework.
You can instantiate in the global scope making the functionality available overall:
var ts = new ParmTran( [ id ] );
id - the form id from where to read the storage data (default by 'transit'):
The encoded data is located between the form tags. The data is decoded and saved, and the form content is cleared. This form and its action attribute are used further to send the requests.
ts.Get( name );
Read the data element from the storage.
ts.Set( name, value );
Write the data element into the storage.
ts.Enc( data [, flag = false ] );
Convert the data to (encoded) json string
ts.Dec( data [, flag = false ] );
Convert the (encoded) json string to the data object
ts.Send( parm [ , meth = 'post' ] );
Send GET/POST request.
ts.Ajax( parm , func [ , meth = 'post' ] );
Make AJAX request.
The callback specified in the Ajax method receives two arguments:
The example.php processes the following requests:
The prompt text under the heading indicates the current status. Examine the example files to follow the class' usage and the communication logic.
Upload the files to any web directory and run the example.php. The following files are included:
Please [contact] on any product-related questions.
[ParmOpts.php]: http://www.phpclasses.org/package/9457.html [contact]: mailto://vallo@vregistry.com
Files |
File | Role | Description |
---|---|---|
example.js | Example | Example script |
example.php | Data | Auxiliary data |
example.phtml | Data | Auxiliary data |
LICENSE | Lic. | License text |
ParmOpts.php | Data | Auxiliary data |
ParmTran.js | Class | Class source |
README.md | Doc. | Documentation |
parameters-transmit-2015-11-15.zip 10KB | |
parameters-transmit-2015-11-15.tar.gz 8KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.