Comments (5)
$.getScript
is just shorthand for $.ajax
. $.getScript(url, callback) becomes $.get(url, undefined, callback, 'script') which in turn becomes jQuery.ajax({url: url, type: 'get', dataType: 'script', data: undefined, success: callback })
What you may be noticing is jQuery switching to XHR rather than using a <script>
tag to load the script. Even though the 'script' dataType is being used, jQuery will still check to see if its really going to be a cross domain request. Only if its a cross domain request does it load via a <script>
tag.
I've also noticed that sometimes the script isn't available because jQuery removes the tag from the DOM once the script has been loaded.
Sometimes I'll just insert a debugger;
statement in my code to set a breakpoint if I either can't find the script or if there are so many scripts I don't feel like looking through them.
from f2.
@brianbaker I think that your explanation is what matches the second link I gave: http://stackoverflow.com/questions/690781/debugging-scripts-added-via-jquery-getscript-function. That also gives a workaround to force the use of script
tag even in the case of local domain. The current jQuery behavior seems to me to be the wrong default behavior -- script
should always be preferred to XHR + eval -- but I'd guess this is to work around IE issues because XHR lifecycle notification is better supported than script lifecycle notification.
I'll try the debugger
suggestion, but from what I've read, it won't actually work. I'd guess that the debugger simply does not have access to the code, so even if it stops, I can't see or inspect the code. I'll report back once I try it.
from f2.
Hi @ilinkuo, any update on how using debugger
went? Were you able to figure out any consistent steps to reproduce the issue?
from f2.
@brianbaker The issue rendered moot when a url was provided so I was no longer hitting localhost -- this problem only occurs when the domains match. But I'm interested in the answer so I'll get back to this either today or tomorrow (4/30).
from f2.
This can be closed. The problem exists only for locally loaded scripts and can be worked around in FFox but not Chrome.
- Scripts loaded by F2 locally using jQuery's ajax do not appear normally in the debuggers for Chrome or FFox (IE not tested). The requests appear in the Chrome Network and FBug Net tabs, but do not appear in the Chrome Sources or FBug Script tab.
- Adding
debugger;
successfully stops the code displaying the source in FBug but not in Chrome. - Apparently, the code is available to FBug, but not as the original file but rather as an eval'ed file. In my case, I expected FBug to show the script at js/streamingNews/prettydate.js but in fact it it showed under f2.debug.js/eval/seq/15.
- The snippet from http://stackoverflow.com/a/691661/1932390 replacing jQuery getScript did not work for me but I didn't spend much time getting it to work.
from f2.
Related Issues (20)
- How to use F2 Registry and Store HOT 2
- Add support for cross-domain Apps HOT 7
- Add bower install to readme HOT 1
- Fix gruntfile.js in bower.json to match case in filename HOT 1
- Create build task in grunt file HOT 1
- change gh-pages task to only copy dist folder under docs HOT 1
- bump version to 1.4.2 HOT 1
- Upload new version to Nuget.org HOT 1
- Container error thrown when using shadow DOM HOT 2
- Issue related to i-pad - Set description as 'Tube'. HOT 2
- Add Failure AppHandler constants HOT 1
- Website examples fail to load HOT 1
- Issue related to i-pad - Set description as 'Tube'
- How to Use f2-autoload on F2.Event.emit or F2.Event.on HOT 3
- Can't recieve event in secure app HOT 1
- Update Libraries w/ Known Security Vulnerabilities HOT 3
- App Class's 'destroy' method is undocumented
- Cannot pass DOM element references in event data HOT 1
- APP_MANIFEST_REQUEST_FAIL is never emitted HOT 2
- Library is breaking if I don't use 'unsafe-inline' in CSP HOT 11
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 f2.