我有一个相对复杂的例程,其中有多个用BabelJS反编译的类,后来用JSCompress进行了手动压缩,其中简单的jQuery.length
测试仅在联机时才起作用。
load( $( 'form' ).attr( 'data-source' ) ).done( ( response ) => {
var nodes = $( jQuery.parseHTML( response ) ).find( '#tags' );
/**
* @internal
*
* Nothing to parse.
* The deferred Chain is rejected and the script flow goes
* to $.whenSync().fail()
*/
if( nodes.length == 0 ) {
$( '#messages' ).find( 'p.nothing' ).removeClass( 'hidden' );
deferred.reject();
}
// Continues, instantiating the Parser Class and building the UI
});
// The fragment below actually is in another file
var cache = {};
function load(url) {
if( ! cache[ url ] ) {
cache[ url ] = $.ajax( url );
}
return cache[ url ];
}
Deferred.reject()是Ben Nadel的jQuery.whenSync()插件的一部分,并触发jQuery的Deferred.done()
在此片段中,我使用了XHR缓存的这种简单方法,当请求完成时,我将响应解析为可操作的HTML。
加载的HTML是由<section id="tags">
包裹的一类分类法的一长串,这就是我用作jQuery.find()
的参数的原因。
但是,如果没有要解析的节点(即没有分类术语),我只是拒绝该链,这会触发来自Ben Nadel插件的jQuery的Deferred.fail(),一旦到达该位置,我就可以使该{{1 }}标签。
我希望您可以看到,至少这部分非常非常简单,并且在本地完美运行。
在线,即使成功地请求了“分类法”页面,<p>
元素仍然存在,并且每次响应文本都被正确地解析为HTML和{ ,当然,其他任何方法都不会起作用。
我精疲力尽。可能有什么问题吗?
路径是正确的,所有库都在文件末尾正确加载,并且在生产中使用的反编译代码或压缩版本都没有问题