Download the PHP package bluepost/blueajax without Composer
On this page you can find all versions of the php package bluepost/blueajax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bluepost/blueajax
More information about bluepost/blueajax
Files in bluepost/blueajax
Package blueajax
Short Description Super-Simple framework for making AJAX easier to deal with on the PHP side
License
Homepage https://github.com/BluePost/BlueAjax
Informations about the package blueajax
Deprecated
This lib has moved to become part of the larger BlueUtils and is not being maintained. It will be removed soon.
BlueAjax
Super-Simple framework for making AJAX easier to deal with on the PHP side. It also includes some JS objects for communicating with an AJAX php script built using this lib.
Getting Started
Installation with Composer (Recommended)
We recommend you install the package with Composer:
Installation
Alternatively you can download the Latest Release, unzip it, and upload the src folder to your environment. Then require it for every file for which you need it.
JavaScript
The javascript components are all in JS/BlueAjax.js file.
TODO
- Make all AjaxResponse functions use respond()
Using BlueAjax
The framework is set up to use "success" and "error" to communicate data. Both the php and js sides rely on this. The data is a string, so we recommend that you use them to communicate the status of the request. This allows for human readable response messages without an unnecessary booleans being passed back and forth.
API Details
PHP
BluePost\AjaxResponse
__construct($baseArray = Array())- The constructor function takes an optional
$baseArraywhich will form the inner response object (seerespond,addResponse)
- The constructor function takes an optional
assert($test, $error, $json = TRUE)- If
$testis FALSE then the function will die with$error. If$jsonis TRUE, then the function will json_encode$error.
- If
isGoodVal($needle, $haystack, $error, $json = TRUE)- If
$needleisn't in$haystackthe function will die with$error. If$jsonis TRUE, then the function will json_encode$error.
- If
isGoodKey($needle, $haystack, $error, $json = TRUE)- If
$needleisn't a valid key for the array$haystackthe function will die with$error. If$jsonis TRUE, then the function will json_encode$error.
- If
condAssert($cond, $test, $error, $json = TRUE)- If
$condis true then the function will callassert($test, $error, $json).
- If
addResponse($key, $value)- This will add the key-value pair to the inner response object which is used when the respond function is called.
respond($response=Array(), $add=TRUE)- This will die with the json_encoded value of
$responsemerged with the inner response array (seeaddResponse). If$addis False then the inner array won't be used.
- This will die with the json_encoded value of
Isset Functions
GETisset($index, $harsh = TRUE)- This function will return TRUE if
$_GET[$index]isset. If$harshis TRUE then the function will usestrictIsset
- This function will return TRUE if
POSTisset($index, $harsh = TRUE)- See
GETissetbut with $_POST
- See
strictIsset($test, $notZero = FALSE, $notEmptyString = TRUE, $notNull = TRUE)- An isset that has a number of extra tests, controlled by the boolean variables
laxIsset ($test, $NES = FALSE)- This uses
strictIssetwith all optional params set to FALSE, except$notEmptyString, which is set to$NES
- This uses