Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Div Value Disappearing

    I am doing a non PHP AJAX request to my server. The request works perfectly and I return the expected value. When I put the response in my div for display, it displays for 1 second and disappears. How I populate the div is below. Does anyone know why my value would not stay displayed?

    <script>
    function Send_AJAX_Request(target)
    {
    // pass the query the user has typed
    // Also, pass the id for a div to update, and the function to call to update this div.
    var user = document.getElementById("Text1").value;
    var pw = document.getElementById("Text2").value;
    var myurl = "verifymember.pgm";
    myurl +="?username=" + escape(user) + "&password=" + escape(pw);
    mydiv = document.getElementById("notauthorized_div");
    // Fire request for data and populate div:
    AJAX_Update(myurl, mydiv, Receive_AJAX_Response);
    }
    // Called from inside the function AJAX_Update:
    function Receive_AJAX_Response(mydiv, response )
    {
    // Display the div at the proper position
    mydiv.innerHTML = response;
    setRespDiv(mydiv);
    }
    </script>

    <form name="frmSignin">
    <div style="width:194px;">
    <div id="signinboxtop"><img src="/art/signin-box-top.gif" width="194" height="7" /></div>
    <div id="signinboxmiddle"> <span class="plaintext"><strong>User Name</strong>
    </span><br />
    <input type="text" name="username" value="" maxlength="10" ID="Text1" />
    <br />
    <br />
    <span class="plaintext"><strong>Password</strong></span><br />
    <input type="password" name="password" value="" maxlength="10" ID="Text2" />
    </div>
    <div id="signinboxbottom">
    <input name="image" type="image" src="/art/signin-box-bottom.jpg" width="194" height="32" onclick="Send_AJAX_Request(this);">
    </div>
    </div>
    <div id="notauthorized_div" style="width:498px;"></div>
    <script language="JavaScript">
    <!--
    document.frmSignin.username.focus();
    //-->
    </script>
    </form>

    Also this url changes after AJAX request: https://mypage/member-log-in.htm
    to: https://mypage/member-log-in.htm?use...=55&image.y=13
    Where would (&image.x=55&image.y=13) come from? Is this the problem?
    Last edited by Joe9999999; 05-30-2006 at 03:38 PM.

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    It would help if you posted the rest of your code like how you're making the XHR calls.

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply. The XHR to my server is working like I want it to. My page is redisplaying, after my AJAX returned value is displayed in the notauthorized_div for about 1 second. That's what I don't understand. What would cause the page to redisplay itself?

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    perhaps the way your XHR's callback is setup. I dunno. Nothing in your code shows me what's actually happening.

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the full script. You're right, I should have put this in to begin with.

    <script>
    var _ms_AJAX_Request_ActiveX = ""; // Holds type of ActiveX to instantiate

    function AJAX_Update(url, obj, func)
    {
    if (!url) return false; // Don't run if missing the url parm.

    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
    var xmlhttp=new XMLHttpRequest();
    }

    // code for IE
    else if (window.ActiveXObject)
    {
    // Instantiate the latest MS ActiveX Objects
    if (_ms_AJAX_Request_ActiveX)
    {
    xmlhttp = new ActiveXObject(_ms_AJAX_Request_ActiveX);
    }
    else
    {
    // loops through the various versions of XMLHTTP to ensure we're using the latest
    var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
    "Microsoft.XMLHTTP"];
    for (var i = 0; i < versions.length ; i++)
    {
    try
    {
    // try to create the object
    // if it doesn't work, we'll try again
    // if it does work, we'll save a reference to the proper one to speed up future instantiations
    xmlhttp = new ActiveXObject(versions[i]);
    if (xmlhttp)
    {
    _ms_AJAX_Request_ActiveX = versions[i];
    break;
    }
    }
    catch (objException)
    {
    // trap - try next one
    }
    }
    }
    }
    if (!xmlhttp) return false;
    if (func)
    xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState != 4) return;
    if (xmlhttp.status == 200)
    func(obj, xmlhttp.responseText);
    else
    alert("An error occurred" + http.status);
    };
    else
    xmlhttp.onreadystatechange = function() { return; }
    // Do the actual request:
    xmlhttp.open('POST', url, true);
    xmlhttp.send(null);

    return false;
    }
    </script>



    <script>
    function Send_AJAX_Request(target)
    {
    // pass the query the user has typed
    // Also, pass the id for a div to update, and the function to call to update this div.
    var user = document.getElementById("Text1").value;
    var pw = document.getElementById("Text2").value;
    var myurl = "verifymember.pgm";
    myurl +="?username=" + escape(user) + "&password=" + escape(pw);
    mydiv = document.getElementById("notauthorized_div");
    // Fire request for data and populate div:
    AJAX_Update(myurl, mydiv, Receive_AJAX_Response);
    }
    // Called from inside the function AJAX_Update:
    function Receive_AJAX_Response(mydiv, response )
    {
    // Display the div at the proper position
    mydiv.innerHTML = response;
    setRespDiv(mydiv);
    }
    </script>



    <form name="frmSignin">
    <div style="width:194px;">
    <div id="signinboxtop"><img src="/art/signin-box-top.gif" width="194" height="7" /></div>
    <div id="signinboxmiddle"> <span class="plaintext"><strong>User Name</strong>
    </span><br />
    <input type="text" name="username" value="" maxlength="10" ID="Text1" />
    <br />
    <br />
    <span class="plaintext"><strong>Password</strong></span><br />
    <input type="password" name="password" value="" maxlength="10" ID="Text2" />
    </div>
    <div id="signinboxbottom">
    <input name="image" type="image" src="/art/signin-box-bottom.jpg" width="194" height="32" onclick="Send_AJAX_Request(this);">
    </div>
    </div>
    <div id="notauthorized_div" style="width:498px;"></div>
    <script language="JavaScript">
    <!--
    document.frmSignin.username.focus();
    //-->
    </script>
    </form>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •