Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript/jQuery中我自己的第一个对象的帮助_Javascript_Jquery_Ajax_Oop - Fatal编程技术网

JavaScript/jQuery中我自己的第一个对象的帮助

JavaScript/jQuery中我自己的第一个对象的帮助,javascript,jquery,ajax,oop,Javascript,Jquery,Ajax,Oop,我编写了一个PHP脚本,用于检查域是否可用于注册 为了自动化这个过程,我还编写了一个js脚本,它自动向PHP脚本发送AJAX调用,并告诉用户域是否可用,而无需提交表单: $(document).ready(function() { function Domain() { this.name = ''; this.dotComRegistered = 1; this.dotNetRegistered = 1; thi

我编写了一个PHP脚本,用于检查域是否可用于注册

为了自动化这个过程,我还编写了一个js脚本,它自动向PHP脚本发送AJAX调用,并告诉用户域是否可用,而无需提交表单:

$(document).ready(function() {

    function Domain() {    
        this.name = '';
        this.dotComRegistered = 1;
        this.dotNetRegistered = 1;
        this.dotOrgRegistered = 1;
    }

    Domain.prototype.check = function(input) {
        this.name = input;

        if (this.name.length >= 3 && this.name.length <= 63) {        
            $.get('check.php', { d : this.name }, function(json) {

                alert(json);

                this.dotComRegistered = $.evalJSON(json).com;
                this.dotNetRegistered = $.evalJSON(json).net;
                this.dotOrgRegistered = $.evalJSON(json).org;

            });
        }
    }

    var domain = new Domain();

    var input = ''

    $('#domain').keyup(function() {

        input = $('#domain').val();
        domain.check(input);

    });

    $('form').submit(function() {

        input = $('#domain').val();
        domain.check(input);
        return false;

    });

});
$(文档).ready(函数(){
函数域(){
this.name='';
this.dotComRegistered=1;
this.dotnetregisted=1;
this.dotOrgRegistered=1;
}
Domain.prototype.check=函数(输入){
this.name=输入;

如果(this.name.length>=3&&this.name.length您是否已通过Firebug?在发出请求的点设置一个断点,并从该点开始执行。代码中的
dn
来自何处


<>也有一个特定的原因,你的域函数在<代码> $(文档).Read()/Case>中吗?它不需要真的存在(你也可以考虑对你的类进行命名空间)。< /P>啊。我在脚本中改写了“DN”到“名字”,我忘记在那里重写它。现在它起作用了:@Richard-很高兴能帮上忙。P.S.你在读哪本Resig书?这本:那是一本很棒的书。我建议你在完成那本书之后,为他的下一本书报名参加MEAP——JavaScript忍者的秘密——昨天开始读,非常有启发性:)关于名称空间,我还不太远:)所以我不知道怎么做。