summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Aker <greg.aker@ellislab.com>2010-11-22 21:42:53 +0100
committerGreg Aker <greg.aker@ellislab.com>2010-11-22 21:42:53 +0100
commit081ac9d44dab334c748c0f7e763c97d55fb9bdf1 (patch)
tree3aad0c9c083319723518daf753b44e35afeddb5f
parent3a563987be22b542a26c05b21a5691c9dd4ec7be (diff)
Adding is_ajax_request() method to CI_Input
-rw-r--r--system/core/Input.php15
-rw-r--r--user_guide/changelog.html2
-rw-r--r--user_guide/libraries/input.html9
3 files changed, 24 insertions, 2 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index 52ea71bc5..6f88b1972 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -624,6 +624,21 @@ class CI_Input {
return $this->headers[$index];
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Is ajax Request?
+ *
+ * Test to see if a request contains the HTTP_X_REQUESTED_WITH header
+ *
+ * @return boolean
+ */
+ public function is_ajax_request()
+ {
+ $req_source = $this->server('HTTP_X_REQUESTED_WITH');
+ return ($req_source == 'XMLHttpRequest') ? TRUE : FALSE;
+ }
+
}
// END Input class
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index d5bf1b77d..c3693e5f9 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -108,7 +108,7 @@ Hg Tag: </p>
Please see the <a href="./installation/upgrade_200.html">upgrade instructions</a> for details.</li>
<li>Altered Form_Validation library to allow for method chaining on <kbd>set_rules()</kbd>, <kbd>set_message()</kbd> and <kbd>set_error_delimiters()</kbd> functions.</li>
<li>Altered Email Library to allow for method chaining.</li>
- <li>Added <kbd>request_headers()</kbd> and <kbd>get_request_header</kbd> to the input class.</li>
+ <li>Added <kbd>request_headers()</kbd>, <kbd>get_request_header()</kbd> and <kbd>is_ajax_request()</kbd> to the input class.</li>
</ul>
</li>
<li>Database
diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html
index 704421331..d838cf020 100644
--- a/user_guide/libraries/input.html
+++ b/user_guide/libraries/input.html
@@ -239,10 +239,17 @@ else<br />
<code>$headers = $this->input->request_headers();</code>
<h2>$this->input->get_request_header();</h2>
-<p>Returns a single
+<p>Returns a single member of the request headers array.</p>
<code>$this->input->get_request_header('some-header', TRUE);</code>
+
+<h2>$this->input->is_ajax_request()</h2>
+<p>Checks to see if the <var>HTTP_X_REQUESTED_WITH</var> server header has been set, and returns a boolean response.</p>
+
+<code>$this->input->is_ajax_request()</code>
+
+
</div>
<!-- END CONTENT -->