Loading ...
Sorry, an error occurred while loading the content.

Invoking a location.href redirect from a connection call

Expand Messages
  • Brandon
    I think I might just be missing something simple here. I have a simple login dialog box, and my server-side page returns a Success or Error message
    Message 1 of 2 , Dec 2, 2006
    • 0 Attachment
      I think I might just be missing something simple here.

      I have a simple login dialog box, and my server-side page returns a
      "Success" or "Error" message (responseText) back into the dialog box.

      What I'd like to do is on a valid login, have it automatically change
      to a different page.

      I've tried:

      - including a <script>window.location.href='page2.html'</script> as
      responseText
      - creating a function on the main page that is invoked from the
      responseText

      using both window.location.href, top.location.href to no avail. (I get
      a "Permission denied to call method Location.toString" which I assume
      is the way the XMLHttpRequest is returned (i.e., no running scripts
      back through XMLHttpRequest).

      Any ideas?
    • Eric Miraglia
      Brandon, Sorry if you already got a reply on this. One approach is to pass back information in your response that indicates whether the login was successful;
      Message 2 of 2 , Dec 4, 2006
      • 0 Attachment
        Brandon,

        Sorry if you already got a reply on this.  One approach is to pass back information in your response that indicates whether the login was successful; you could do that in XML, JSON, or just as a string.  In your Connection Manager success callback (click here for more on the callback object), you could then evaluate the data that came back and, if the login was successful, do the redirect right there.

        Just using a plain "success" string as the data passed, you could do something like this:

        <script>
        YAHOO.util.Event.on("clickme","click",function(e) {

        var success = function(o) {
        if(o.responseText == "success") {location.href="http://www.yahoo.com";}
        }

        var callback = {"success": success};
        var oCon = YAHOO.util.Connect.asyncRequest('GET','checklogin.html',callback);

        });
        </script>
        </head>

        <body>
        <div id="clickme">Click here to actuate the event.</div>
        </body>
        </html>

        NOTE: This implies that there's a file "checklogin.html" that would return nothing more than the string "success" upon a successful login.

        Regards,
        Eric


        ______________________________________________
        Eric Miraglia
        Yahoo! Presentation Platform Engineering



        On Dec 2, 2006, at 7:38 PM, Brandon wrote:

        I think I might just be missing something simple here.

        I have a simple login dialog box, and my server-side page returns a
        "Success" or "Error" message (responseText) back into the dialog box.

        What I'd like to do is on a valid login, have it automatically change
        to a different page.

        I've tried:

        - including a <script>window.location.href='page2.html'</script> as
        responseText
        - creating a function on the main page that is invoked from the
        responseText

        using both window.location.href, top.location.href to no avail. (I get
        a "Permission denied to call method Location.toString" which I assume
        is the way the XMLHttpRequest is returned (i.e., no running scripts
        back through XMLHttpRequest).

        Any ideas?


      Your message has been successfully submitted and would be delivered to recipients shortly.