Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BrowserKit] Documented the new xmlHttpRequest() method#9518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:masterfromjaviereguiluz:fix_9381
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletionscomponents/browser_kit.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,6 +75,19 @@ The value returned by the ``request()`` method is an instance of the
:doc:`DomCrawler component </components/dom_crawler>`, which allows accessing
and traversing HTML elements programmatically.

The :method:`Symfony\\Component\\BrowserKit\\Client::xmlHttpRequest` method,
which defines the same arguments as the ``request()`` method, is a shortcut to
make AJAX requests::

use Acme\Client;

$client = new Client();
// the required HTTP_X_REQUESTED_WITH header is added automatically
$crawler = $client->xmlHttpRequest('GET', '/');

.. versionadded:: 4.1
The ``xmlHttpRequest()`` method was introduced in Symfony 4.1.

Clicking Links
~~~~~~~~~~~~~~

Expand Down
22 changes: 17 additions & 5 deletionstesting.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -359,8 +359,8 @@ returns a ``Crawler`` instance.
)

The ``server`` array is the raw values that you'd expect to normally
find in the PHP `$_SERVER`_ superglobal. For example, to set the ``Content-Type``,
``Referer`` and ``X-Requested-With`` HTTP headers, you'd pass the following (mind
find in the PHP `$_SERVER`_ superglobal. For example, to set the
``Content-Type`` and ``Referer`` HTTP headers, you'd pass the following (mind
the ``HTTP_`` prefix for non standard headers)::

$client->request(
Expand All@@ -369,9 +369,8 @@ returns a ``Crawler`` instance.
array(),
array(),
array(
'CONTENT_TYPE' => 'application/json',
'HTTP_REFERER' => '/foo/bar',
'HTTP_X-Requested-With' => 'XMLHttpRequest',
'CONTENT_TYPE' => 'application/json',
'HTTP_REFERER' => '/foo/bar',
)
);

Expand DownExpand Up@@ -441,6 +440,19 @@ script::

$client->insulate();

AJAX Requests
~~~~~~~~~~~~~

The Client provides a :method:`Symfony\\Component\\BrowserKit\\Client::xmlHttpRequest`
method, which has the same arguments as the ``request()`` method, and it's a
shortcut to make AJAX requests::

// the required HTTP_X_REQUESTED_WITH header is added automatically
$client->xmlHttpRequest('POST', '/submit', array('name' => 'Fabien'));

.. versionadded:: 4.1
The ``xmlHttpRequest()`` method was introduced in Symfony 4.1.

Browsing
~~~~~~~~

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp