Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery.get:jQuery.post: Document issues with data: null with 3 params #1208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion entries/jQuery.get.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<argument name="data" type="PlainObject" />
<argument name="textStatus" type="String"/>
<argument name="jqXHR" type="jqXHR"/>
<desc>A callback function that is executed if the request succeeds. Required if <code>dataType</code> is provided, but you can use <code>null</code> or <a href="/jQuery.noop/"><code>jQuery.noop</code></a> as a placeholder.</desc>
<desc>A callback function that is executed if the request succeeds. Required if <code>dataType</code> is provided, but you can use <code>null</code> or <a href="/jQuery.noop/"><code>jQuery.noop</code></a> as a placeholder. <strong>NOTE:</strong> In jQuery 3.x and older, when providing a <code>null</code> value for <code>success</code> you also have to provide the <code>data</code> parameter; you can set it to <code>undefined</code>.</desc>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can set it to undefined or null right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically - probably yes - but I'd rather not advertise that. For example, in the success case, you can set it to null but not to undefined to trigger the documented behavior, which makes us treat the undefined value more as "parameter not passed" and null having some extra meanings in some cases.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk, it seems inconsistent to recommend null in one place and undefined in another. I'd probably use null, null, dataType myself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to document null for the second parameter as well, we'd have to have some tests in jQuery for this. Currently, I believe we have none.

</argument>
<argument name="dataType" optional="true" type="String">
<desc>The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).</desc>
Expand Down
2 changes: 1 addition & 1 deletion entries/jQuery.post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<argument name="data" type="PlainObject" />
<argument name="textStatus" type="String"/>
<argument name="jqXHR" type="jqXHR"/>
<desc>A callback function that is executed if the request succeeds. Required if <code>dataType</code> is provided, but can be <code>null</code> in that case.</desc>
<desc>A callback function that is executed if the request succeeds. Required if <code>dataType</code> is provided, but can be <code>null</code> or <a href="/jQuery.noop/"><code>jQuery.noop</code></a> as a placeholder. <strong>NOTE:</strong> In jQuery 3.x and older, when providing a <code>null</code> value for <code>success</code> you also have to provide the <code>data</code> parameter; you can set it to <code>undefined</code>.</desc>
</argument>
<argument name="dataType" optional="true" type="String">
<desc>The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).</desc>
Expand Down