Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here' a small chunk of a JavaScript PHP wrapper I wrote a long time ago when I virtually knew nothing about JavaScript... it barely contains any AJAX methods, just wrapper functions that communicate with a PHP backend in order to allow PHP to do all the work... </p> <p>In all honesty, to get what it seems you're looking for... just sit down and write yourself an AJAX library with all the common helper functions. It should take you a few hours at the most.</p> <p><strong>The Javascript:</strong></p> <pre><code>(function() { var PHPJS = window.PHPJS = window.$ = function() { return new PHPJS.Strings; }; PHPJS.Strings = PHPJS.prototype = { InitAJAX: function(Library, ServerString) { var ResultCache = document.body; var FunctionRequest; try { FunctionRequest = new XMLHttpRequest(); } catch (e) { try { FunctionRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { FunctionRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { throw new Error("The XMLHttpRequest() object is not supported by your browser.") return false; } } } FunctionRequest.onreadystatechange = function() { if (FunctionRequest.readyState == 4 &amp;&amp; FunctionRequest.status == 200) { ResultCache.innerHTML = FunctionRequest.responseText; return FunctionRequest.responseText; } } switch (Library) { case 'Arrays' : FunctionRequest.open("GET", "functions/arrays-lib.php" + ServerString, true); break; case 'Math' : FunctionRequest.open("GET", "functions/math-lib.php" + ServerString, true); break; case 'Strings' : FunctionRequest.open("GET", "functions/strings-lib.php" + ServerString, true); break; } FunctionRequest.send(null); }, /* String Functions */ addcslashes: function(str, charlist) { return this.InitAJAX('Strings','?function=addcslashes&amp;String='+str+'&amp;Charlist='+charlist); }, addslashes: function(str) { return this.InitAJAX('Strings','?function=addslashes&amp;String='+str); }, bin2hex: function(str) { return this.InitAJAX('Strings','?function=bin2hex&amp;String='+str); }, chop: function(str,charlist) { return this.InitAJAX('Strings','?function=chop&amp;String='+str+'&amp;Charlist='+charlist); }, chr: function(int) { return this.InitAJAX('Strings','?function=chr&amp;Int='+int); }, chunk_split: function(str, chunklen, end) { return this.InitAJAX('Strings','?function=chunk_split&amp;String='+str+'&amp;Chunklen='+chunklen+'&amp;End='+end); }, convert_cyr_string: function(str) { return this.InitAJAX('Strings','?function=convert_cyr_string'); }, /* more functions... */ } })(); //PHPJS.bin2hex('afsdfadsafdsafdasfsaf'); </code></pre> <p><strong>The PHP:</strong></p> <pre><code>&lt;?php switch($_GET['function']) { case 'addcslashes' : $charlist = (@$_GET['Charlist']) ? ','.$_GET['Charlist'] : ''; echo addcslashes($_GET['String'], $charlist); break; case 'addslashes' : echo addslashes($_GET['String']); break; case 'bin2hex' : echo bin2hex($_GET['String']); break; case 'chop' : $charlist = (@$_GET['Charlist']) ? ','.$_GET['Charlist'] : ''; echo rtrim($_GET['String'], $charlist); break; case 'chr' : echo chr($_GET['Int']); break; case 'chunk_split' : echo chunk_split($_GET['String'], @$_GET['Chunklen'], @$_GET['End']); break; /** ...etc, etc... **/ ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload