Skip to content

jQuery.ajax docs contain contradictory statements about "html" dataType behaviour #482

Closed
@ExplodingCabbage

Description

@ExplodingCabbage

The jQuery.ajax docs contain the following two statements about the behaviour of the "html" dataType:

"html": Returns HTML as plain text; included script tags are evaluated _when inserted in the DOM_.

...

If html is specified, any embedded JavaScript inside the retrieved data is executed _before the HTML is returned_ as a string.

(emphasis mine).

Unless I am misinterpreting what I am reading, these statements directly contradict each other.

If I understand it correctly, the second statement means that if I send an ajax call to somefile.html and get a response of

<html>
    <script>
        alert('hello world');
    </script>
</html>

then I should see the alert immediately upon receiving the response, even if I never add the response text to the DOM. This does not in fact happen, at least in the versions of jQuery I tried (1.4.0 and 2.1.0). As far as I can tell, the second statement is thus simply false and should be removed.

My apologies if I have somehow misunderstood the second quoted sentence, which seems quite possible - the behaviour that I interpret it as describing would be rather bizarre if it were in fact implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions