In our app (web and mobile), we load in jQuery using either the Google CDN, or a normal tag. This loads in the requested source map (.map) file correctly, from the same directory as the requested jQuery file ('/assets/js').
在我们的应用程序(web和mobile)中,我们使用谷歌CDN或普通标记来加载jQuery。这将从与请求的jQuery文件('/assets/js')相同的目录中正确地加载所请求的源映射(.map)文件。
However, we also use Ajax to load in specific JS files, one of which is jQuery Mobile. Because jQuery Mobile is being loaded by Ajax, for some reason it tries to load in the .map file from the root, rather than the 'assets/js' directory.
但是,我们也使用Ajax加载特定的JS文件,其中之一就是jQuery Mobile。由于jQuery Mobile正在被Ajax加载,出于某种原因,它试图从根目录加载.map文件,而不是“assets/js”目录。
I know the simple solution is to drop the .map file into the root to get rid of the annoying 404 errors (or turn of source maps in Chrome), but I'd like to understand why this occurs when loading the JS files via Ajax.
我知道简单的解决方案是将.map文件放到根目录中,以消除恼人的404错误(或在Chrome中转换源映射),但是我想知道为什么在通过Ajax加载JS文件时会发生这种情况。
Any ideas why this happens, and how to overcome it?
你知道为什么会发生这种事吗?
1 个解决方案
#1
3
Similar question to earlier:
之前类似的问题:
Error 'jquery-2.0.2.min.map not found'
错误的jquery-2.0.2.min。地图上找不到的
Starting with jQuery 1.9, we also make available sourcemap files that can be used to debug the compressed file in sourcemap-aware browsers such as Google Chrome. The map file is not required for users to run jQuery, it just improves the developer's debugger experience.
从jQuery 1.9开始,我们还提供了可用的sourcemap文件,这些文件可以用于调试支持源代码的浏览器(如谷歌Chrome)中的压缩文件。用户不需要使用映射文件来运行jQuery,它只是改进了开发人员的调试器体验。
So as long as you're seeing this in Chrome it is only for your benefit!
所以只要你在Chrome上看到这个,这只是为了你的利益!
However to answer why this happens when loading from AJAX I guess it's because it references the source map relatively and your ajax is being called from a page on your server/document root.
然而,要回答从AJAX加载时发生这种情况的原因,我猜是因为它相对地引用了源映射,而您的AJAX是从服务器/文档根上的一个页面调用的。
#1
3
Similar question to earlier:
之前类似的问题:
Error 'jquery-2.0.2.min.map not found'
错误的jquery-2.0.2.min。地图上找不到的
Starting with jQuery 1.9, we also make available sourcemap files that can be used to debug the compressed file in sourcemap-aware browsers such as Google Chrome. The map file is not required for users to run jQuery, it just improves the developer's debugger experience.
从jQuery 1.9开始,我们还提供了可用的sourcemap文件,这些文件可以用于调试支持源代码的浏览器(如谷歌Chrome)中的压缩文件。用户不需要使用映射文件来运行jQuery,它只是改进了开发人员的调试器体验。
So as long as you're seeing this in Chrome it is only for your benefit!
所以只要你在Chrome上看到这个,这只是为了你的利益!
However to answer why this happens when loading from AJAX I guess it's because it references the source map relatively and your ajax is being called from a page on your server/document root.
然而,要回答从AJAX加载时发生这种情况的原因,我猜是因为它相对地引用了源映射,而您的AJAX是从服务器/文档根上的一个页面调用的。