UserId可用性检查文本框不起作用 [英] UserId availability check textbox is not working

查看:53
本文介绍了UserId可用性检查文本框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的输入按钮:
<input id="btnDoAjaxCall" type="button" value="Check Availability" onclick="return btnDoAjaxCall_onclick()" />
但是当我单击此按钮时不起作用.

我还在项目中使用了母版页.
这是我的JavaScript代码:

<script language="javascript" type="text/javascript">
    function btnDoAjaxCall_onclick() {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("showAvailability").innerHTML = xmlhttp.responseText;
            }
        }
        var str = document.getElementById("txtEmail").value;
        //sending request to handler page
        xmlhttp.open("GET", "Handler.ashx?uname=" + str, true);
        xmlhttp.send();
    }
    </script>



我将此代码写在母版页的开头.我还检查了此代码以放置在
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

但它不起作用.请帮助我如何解决此问题.
这段代码在我以前的项目中正常工作,其中我没有使用母版页.但是在使用母版页后,它不起作用.请帮助我.
在此先感谢


谁能告诉我在哪里可以编写此javascript代码. txtEmail文本框和showAvailability div是我的另一页.
我认为您应该养成调试的习惯.您可以使用Firefox中的Firebug插件调试Javascript.一步一步检查步骤,请求是否到达Handler.ashx页面?如果是这样,它是否会返回正确的响应?

还建议将jQuery或Prototype库用于Ajax调用,不建议使用纯XmlHttpRequest(用于简单内容的代码太多,还有更多问题).

或者,您必须将整个代码发送给我们.


I am using a input button like this:
<input id="btnDoAjaxCall" type="button" value="Check Availability" onclick="return btnDoAjaxCall_onclick()" />
but when i click this button it does not work.

i also used master page in the project.
this is my javascript code:

<script language="javascript" type="text/javascript">
    function btnDoAjaxCall_onclick() {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("showAvailability").innerHTML = xmlhttp.responseText;
            }
        }
        var str = document.getElementById("txtEmail").value;
        //sending request to handler page
        xmlhttp.open("GET", "Handler.ashx?uname=" + str, true);
        xmlhttp.send();
    }
    </script>



I write this code in head of the master page. i also check this code to placed in the
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

but it does not work. Please help how can i solve this.
This code is working in my previous project where i not used master page. But after using master page it does not work. Please help me for do this.
Thanks in advance


can any one tell me where i can write this javascript code. txtEmail textbox and showAvailability div is my another page.

解决方案

The code looks right, but as you say there is a problem somewhere.

I think you should get in the habit of debugging. You can debug Javascript using Firebug add on in Firefox. Check the steps one by one, does the request hit the Handler.ashx page? If so does it return a proper response?

Also use jQuery or Prototype libraries for Ajax calls, using plain XmlHttpRequest is not encouraged (too much code for simple stuff plus few more issues).

Alternatively you have to send your whole code to us so.


这篇关于UserId可用性检查文本框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆