Comments (14)
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.
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.
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.
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.
Comment author: dmethvin
Seems valid enough to keep open, until we figure out why we're removing the hash.
from jquery.
Comment author: dmethvin
Okay, this gives me an error from Facebook because of the xxx id:
This gives the same error and doesn't have the hash as timmywil said:
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.
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.
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.
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.
This was unlocked by b091fdb, but we might want a distinct ticket for AJAX hash preservation.
from jquery.
Agreed, since it's potentially a breaking change it's a good 3.0 candidate.
from jquery.
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.
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.
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)
- Deprecation / Warning | jQuery CDN HOT 4
- Cannot read properties of null (reading 'compareDocumentPosition') HOT 3
- Invalid links in blog article HOT 2
- The jquery.factory.js bundle is missing in the npm package in the 4.0.0-beta release HOT 2
- `require( "jquery" )` returns a module object when used with Webpack & jQuery 4.0.0-beta HOT 24
- v4 beta : mottie/tablesorter plugin fails with sort() and trim() missing HOT 1
- Jquery-UI getting Error With jQuery jQuery 4.0.0 BETA! HOT 4
- jQuery.get() 4.0 backward compatibility issue HOT 3
- Permissions policy violation due to unload event HOT 1
- Avoiding JQuery version disclosure on Angular's Script.JS HOT 1
- Scripts in dynamically set html always asynchronously loaded HOT 3
- jQuery 3.7.1 is still making wrong calculation of dimensions in Firefox. HOT 1
- Memory Leak: OriginAnchor HOT 6
- Memory Leak: boxSizingReliable HOT 4
- Triggering after an `alert()` in an event handler results in a JS error HOT 2
- The strange behavior generated by the append method HOT 1
- Avoid counting scroll twice in offset
- jQuery Migrate 3.4.0 - elem.focus() is not working HOT 3
- Issue or behaviour??? - 2.2.3 to 3.6.0 - active element changed on focus. HOT 2
- Issue using JQuery 3.7.1 and CSP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.