首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prototype Ajax.Request永不返回

Prototype Ajax.Request永不返回
EN

Stack Overflow用户
提问于 2010-08-14 06:32:19
回答 1查看 343关注 0票数 0

我正在尝试学习Prototype,所以我拼凑了一个简单的登录页面,带有用户名和密码字段,以及一个登录按钮。

我有一个控制器类,我想在其中放置我所有的onclick函数。

代码语言:javascript
复制
function Controller()
{
    this.logIn = function(){
        this.username = Field.getValue("username");
        this.password = Field.getValue("password");

        this.logInResults = function (response){
            alert(response.responseText);
        }

        new Ajax.Request("../../php/tis/LogIn.php",
            {
                method:'get',
                parameters: {username: this.username, password: this.password},
                onComplete: this.logInResults
            });
    }
}

然而,当我单击附加了LogIn函数的按钮时,HTTP请求被发送,但返回一个空的响应字符串。当我手动点击链接到php页面时,它就在那里,并且功能正常。

Firebug显示以下内容:

代码语言:javascript
复制
GET http://localhost/AJAXSeedOrder/php/tis/LogIn.php?username=User%20Name&password=
Firebug cannot find _firebugConsole element true Window tis?username=User+Name
Firebug cannot find _firebugConsole element true Window tis?username=User+Name
Firebug cannot find _firebugConsole element true Window tis?username=User+Name

我完全不知所措--任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-08-14 12:11:23

事实证明,我的问题出在用于将controller.logIn绑定到表单提交按钮的Event.observe调用中。通过observe调用调用LogIn将发出AJAX请求,然后重新加载页面-这将比then服务器返回我的请求更快。

这就是为什么请求会返回空响应字符串的原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3481110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档