Skip to content

Commit 0a182ad

Browse files
authored
Merge pull request #819 from dougblackjr/feature/4108-add-http-code-to-fxn
Adding docs for send_ajax_response
2 parents 6a204a3 + f4e24a4 commit 0a182ad

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/development/legacy/libraries/output.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ Example:
159159

160160
NOTE: **Note:** Calling this method manually without aborting script execution will result in duplicated output.
161161

162-
### `send_ajax_response($msg, [$error = false])`
162+
### `send_ajax_response($msg, [$statusCode = false])`
163163

164164
| Parameter | Type | Description |
165165
| --------- | -------- | -------------------- |
166166
| \$msg | `Array` | Object to be sent to the client. |
167-
| \$error | `Bool` | TRUE to set header status to `500` |
167+
| \$error | `Bool|Int` | HTTP status code. If `false`, status code is `200`. If `true`, status code is 500 |
168168
| Returns | `Void` | void |
169169

170170
Calling this method encode the given `$msg` parameter and will set the header `Content-Type: application/json`.
@@ -176,3 +176,22 @@ Example:
176176
'foo' => 'bar'
177177
);
178178
ee()->output->send_ajax_response($output);
179+
180+
With status code (401):
181+
182+
```
183+
$output = array(
184+
'sucess' => 'false',
185+
'message' => 'not allowed',
186+
);
187+
ee()->output->send_ajax_response($output, 401);
188+
```
189+
190+
As error with standard 500 error code:
191+
192+
```
193+
$output = array(
194+
'sucess' => 'false',
195+
'message' => 'not allowed',
196+
);
197+
ee()->output->send_ajax_response($output, true);

0 commit comments

Comments
 (0)