diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-09-29 18:16:03 -0700 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-09-29 18:16:03 -0700 |
commit | bfdb9bb8a87a29038ba1ae25355684ae19678fdd (patch) | |
tree | a074e2d6bfa19c17b284c3950b4555cf584eabe2 /engine/lib/actions.php | |
parent | 7be23080f34a8f92ca1f8d49c3aa0e6ce3472f4c (diff) | |
parent | a458ae4e0f8e5b19884860fead6e5f901b95eca4 (diff) | |
download | elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.gz elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.bz2 |
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'engine/lib/actions.php')
-rw-r--r-- | engine/lib/actions.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 4ccffd267..99e22e104 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -446,7 +446,17 @@ function ajax_forward_hook($hook, $type, $reason, $params) { $params['status'] = -1; } - header("Content-type: application/json"); + // Check the requester can accept JSON responses, if not fall back to + // returning JSON in a plain-text response. Some libraries request + // JSON in an invisible iframe which they then read from the iframe, + // however some browsers will not accept the JSON MIME type. + if (stripos($_SERVER['HTTP_ACCEPT'], 'application/json') === FALSE) { + header("Content-type: text/plain"); + } + else { + header("Content-type: application/json"); + } + echo json_encode($params); exit; } |