jQuery文件包含问题(未返回错误)

时间:2016-06-17 14:27:35

标签: javascript jquery

我正在研究一些客户端包含的代码,但由于某种原因它没有这样做。 控制台也没有返回任何错误。 这是完整的代码:

的index.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title></title>
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="inc.js"></script>

</head>
<body>

    <p class="inc:footer.html">This text will be replaced with footer.html</p>


</body>
</html>

inc.js:

(function($) {
    $.fn.inc = function(url, transform, post, t) {
        return this.length && url ? this.each(function() {
            t = $(this);
            $.ajax({
                url: url,
                success: function(txt, jqXHR, textStatus) {
                    t.html($.isFunction(transform) ? transform(txt, url) : txt);
                    $.isFunction(post) && post(url, jqXHR, textStatus);
                }
            });
        }) : this;
    };

    $(function() {
        $('[class*="inc:"]').each(function() {
            var match = /inc:(\S+)/.exec(this.className || '');

            if(typeof match[1] != "undefined");


        });
    });

})(jQuery);

footer.html

<div>I am a footer</div>

我在这里错过了什么或做错了什么?

0 个答案:

没有答案