search

Home  >  Q&A  >  body text

javascript - zepto 错误

index.html

<script src="//cdn.staticfile.org/zepto/1.1.4/zepto.min.js"></script>
<script src="./assets/js/script.js"></script>
<script>
    $(function(){
        hsh.home();
        hsh.init();
    });
</script>

script.js

var hsh = (function($){

    return {

        init: function(){

            //ajax 默认设置
            $.ajaxSetting({

                type: "post",
                url: apiUrl,
                dataType : "json",
                async: true,
                error: function(xhr, errorType, error){

                },
                beforeSend: function(xhr, setting){

                },
                success: function(data, status, xhr){

                },
                complete: function(xhr, status){

                }
            });

            alert("init");
            //init.End
        },

        home: function(){

            alert("home");
        }
    }

})(Zepto);

FireBug 报错

TypeError: $.ajaxSetting is not a function

alert("init"); 也没执行!

不知道 这种方式的 zepto 应该怎么写! 求大神指教! -_-|||

PHP中文网PHP中文网2902 days ago315

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-10 14:48:38

    看Doc: http://zeptojs.com/#$.ajaxSettings

    ajaxSettings而不是ajaxSetting

    reply
    0
  • Cancelreply