Giter VIP home page Giter VIP logo

Comments (14)

mgol avatar mgol commented on May 21, 2024

Comment author: pferreir

I forgot to add that in the first case the element seems to be added to the DOM only to be immediately removed.

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: dmethvin

Why not use $.getScript ?  http://api.jquery.com/jQuery.getScript/

Can you provide a complete test case on jsfiddle.net? That would help us evaluate the problem.

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: pferreir

Hello,

Here is a small example:  http://jsfiddle.net/RQVsa/

The uncommented code should work (show the "Like" button), while the commented on should fail. I tried $.getScript, with no success...

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: timmywil

We filter out scripts in manipulation. getScript should be used, but we remove hashes from the url. I'm not sure why, but it's been there a while.

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: dmethvin

Seems valid enough to keep open, until we figure out why we're removing the hash.

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: dmethvin

Okay, this gives me an error from Facebook because of the xxx id:

 http://jsfiddle.net/RQVsa/10/

This gives the same error and doesn't have the hash as timmywil said:

 http://jsfiddle.net/RQVsa/11/

Since the script hasn't yet been executed the .insertBefore() is making the ajax request to request the script, but since the hash is stripped it's never going to see the correct id.

@jaubourg, do you know why we're stripping off the hash? Is there a specific reason for it, or just an omission?

from jquery.

mgol avatar mgol commented on May 21, 2024

Comment author: gibson042

A trip through the wayback machine reveals that we've been stripping hashes since 1.4.2's  fix for #4987.

I'd be in favor of preserving them, but if #3808 kills it for oldIE (and thus 1.9) then we may be unable to while maintaining API symmetry.

from jquery.

dmethvin avatar dmethvin commented on May 21, 2024

Hmmm. Now that we are attempting to parse the URL a bit more sanely per gh-1875 it might be possible to preserve the hash now.

from jquery.

dmethvin avatar dmethvin commented on May 21, 2024

By golly I think we can. After gh-1880 lands the hash is conveniently in ajaxLocation.hash and we could re-append it after adding any serialized params.

from jquery.

gibson042 avatar gibson042 commented on May 21, 2024

This was unlocked by b091fdb, but we might want a distinct ticket for AJAX hash preservation.

from jquery.

dmethvin avatar dmethvin commented on May 21, 2024

Agreed, since it's potentially a breaking change it's a good 3.0 candidate.

from jquery.

dmethvin avatar dmethvin commented on May 21, 2024

Looking at the WHATWG XHR spec they have intentionally taken the hash (fragment) off the URL in the responseURL property. @jaubourg do you know why that might be, or who we might ask? In the OP's reported case it was a script tag but I am wondering if there is more to the reasoning for excluding it for XHR.

Edit: Additional info here seems to indicate stripping the fragment early is okay: https://lists.w3.org/Archives/Public/public-webapps-github/2015Jul/1046.html

from jquery.

gibson042 avatar gibson042 commented on May 21, 2024

Fragments are never sent to servers, and are apparently not even exposed on fetches. But they can appear in the DOM and be visible to executing scripts. It's an extremely rare case to be sure, but one that script transports are technically wrong on as long as we strip them.

from jquery.

modeckimellett avatar modeckimellett commented on May 21, 2024

Interesting. I asked a Stack Overflow question about this a while ago and never got a response. I'll add a link to this issue and the pull request to the question in comments. Thanks for working on this everyone!

For reference, my question is at http://stackoverflow.com/questions/32855458/jquery-ajax-content-from-an-end-point-which-responds-differently-depending-on-th

from jquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.