Skip to content

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

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

Closed
ExplodingCabbage opened this issue Apr 23, 2014 · 1 comment

Comments

@ExplodingCabbage
Copy link
Contributor

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.

@dmethvin
Copy link
Member

Wow, so much better! 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants