summaryrefslogtreecommitdiff
path: root/itjs.class
diff options
context:
space:
mode:
Diffstat (limited to 'itjs.class')
-rw-r--r--itjs.class15
1 files changed, 13 insertions, 2 deletions
diff --git a/itjs.class b/itjs.class
index ac56032..e5c0b25 100644
--- a/itjs.class
+++ b/itjs.class
@@ -17,6 +17,17 @@ class itjs
{
/**
+ * Send HTTP headers (content-type) to transmit javascript code
+ */
+function send_headers()
+{
+ if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT'])) # text/plain breaks Opera 8.51/Linux
+ header('Content-Type: text/plain; charset=iso-8859-1'); # Berni reported some Firewalls to require this
+
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time()+10) . ' GMT'); # prevent broken data on IE reloads
+}
+
+/**
* Serialize the result into a javascript script
* @param $values Array with values to be serialized
* @param $callback Javascript function to call with data (iframe solution)
@@ -38,7 +49,7 @@ function serialize($values)
*/
function encode($values)
{
- $texts = ($values === array_values($values)) ? "[]0" : "{}1"; # Numerical or associative array
+ $texts = ($values === array_values($values)) ? "[]0 " : "{}1\n"; # Numerical or associative array
$result = $texts{0};
@@ -62,7 +73,7 @@ function encode($values)
else
$result .= itjs::encode($value);
- $separator = ",\n";
+ $separator = "," . $texts{3};
}
$result .= $texts{1};