Git Product home page Git Product logo

Comments (4)

chenhuiYj avatar chenhuiYj commented on September 13, 2024

不好意思,之前因为工作忙,没有时间看github。
首先,谢谢您提的建议,您的建议很好,在我新提交的代码里面,我也修改了很多!
然后,ajax那个方法,当readyState的状态为2和3的时候,就会执行obj.error(xmlHttp.responseText);。为什么捕捉不到?
最后如果您在代码那里添加了什么,可以提交上来,我看着合并,大家一起维护!

from ec-do.

seayao avatar seayao commented on September 13, 2024

关于ajax那个我表述错了:
原文:

xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                obj.success(xmlHttp.responseText);
            } else {
                obj.error(xmlHttp.responseText);
            }
        };

问题:经测试请求成功的情况下,err信息会打印两次而且优先于succ的输出,err的第一次打印是空数据(应该是readyState为2的情况),err的第二次打印是正常请求的数据(应该是readyState为2的情况),接下来是succ的正常输出;请求出错的情况下,err会打印三次,第一次为空,后两次是err信息。
我的改写:

xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                //此处可添加一个complete()方法
                if (xmlHttp.status >= 200 && xmlHttp.status < 300 || xmlHttp.status == 304) {
                    obj.success(JSON.parse(xmlHttp.responseText));
                } else {
                    //建议将xmlHttp对象返回,有时候需要根据状态码来进行错误处理
                    obj.error(xmlHttp);
                }
            } else {
                //进行处理也可以忽略
            }
        };

关键在于 if (xmlHttp.readyState == 4)的判断问题,会导致xmlHttp.responseTextreadyState =2和3的时候也正常输出了。不知道我的解释你是否明白。

另外我把你的源码改了一些(甚至包括方法名),也进行了重新分组,注释也重新整理了,还添加了一些方法,直接提交好像不太好。

这是我的一个库:https://github.com/barnboo/pubsea/blob/master/js/pubSea.js,其中的README.md里面有关于这个库(也就是你的库)的一些规划,是有打算联系你和你一起完善的想法的。
弄出来一个类似:http://jquery.cuishifeng.cn/index.html这个网站的,当然这是很好的设想了。

哈哈。

----------------------分割线--------------------------
链接是对的,不知道为什么打开就是404。- -!
复制出来居然可以打开。。。

from ec-do.

seayao avatar seayao commented on September 13, 2024

比如你的getCount()方法,
我改为了arrGroupToArr()方法又增加了一个arrGroupToObj()方法(在SO社区比较有名的jsgroup);
增加了getSameFromArray()获取两个数组相同的元素的方法;
增加了removeArrayOfIndex()删除数组中下标为n的元素的方法;
增加了与时间相关的7个方法包括你原来的getEndTime()方法;
等等。
还有一些自己写的美观的加载动画和闪烁、抖动(类似于提醒的功能)、滚动的插件等等没有添进去。

from ec-do.

chenhuiYj avatar chenhuiYj commented on September 13, 2024

我看了一下,是不是贴错地址了?页面是404!不过我进入你的主页,也找到了这个仓库!
关于版权,我很高兴,因为您是一个很尊重版权的开发者!
关于提交,你那边进行了重新分组,注释也重新整理了,这个没事,到时候我这里合并就好,新开一个仓库。我也想大家一起维护一个!你从我这里fork一份,然后自己修改,提交,我这里就能收到新拉请求了,就可以合并了!

from ec-do.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.