@@ -359,8 +359,8 @@ returns a ``Crawler`` instance.
359
359
)
360
360
361
361
The ``server `` array is the raw values that you'd expect to normally
362
- find in the PHP `$_SERVER `_ superglobal. For example, to set the `` Content-Type ``,
363
- ``Referer `` and ``X-Requested-With `` HTTP headers, you'd pass the following (mind
3
8000
62
+ find in the PHP `$_SERVER `_ superglobal. For example, to set the
363
+ ``Content-Type `` and ``Referer `` HTTP headers, you'd pass the following (mind
364
364
the ``HTTP_ `` prefix for non standard headers)::
365
365
366
366
$client->request(
@@ -369,9 +369,8 @@ returns a ``Crawler`` instance.
369
369
array(),
370
370
array(),
371
371
array(
372
- 'CONTENT_TYPE' => 'application/json',
373
- 'HTTP_REFERER' => '/foo/bar',
374
- 'HTTP_X-Requested-With' => 'XMLHttpRequest',
372
+ 'CONTENT_TYPE' => 'application/json',
373
+ 'HTTP_REFERER' => '/foo/bar',
375
374
)
376
375
);
377
376
@@ -441,6 +440,19 @@ script::
441
440
442
441
$client->insulate();
443
442
443
+ AJAX Requests
444
+ ~~~~~~~~~~~~~
445
+
446
+ The Client provides a :method: `Symfony\\ Component\\ BrowserKit\\ Client::xmlHttpRequest `
447
+ method, which has the same arguments as the ``request() `` method, and it's a
448
+ shortcut to make AJAX requests::
449
+
450
+ // the required HTTP_X_REQUESTED_WITH header is added automatically
451
+ $client->xmlHttpRequest('POST', '/submit', array('name' => 'Fabien'));
452
+
453
+ .. versionadded :: 4.1
454
+ The ``xmlHttpRequest() `` method was introduced in Symfony 4.1.
455
+
444
456
Browsing
445
457
~~~~~~~~
446
458
0 commit comments