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

Newbie connection manager question...

Expand Messages
  • smehrabi
    Hi folks, I m trying to do the following with the YUI Connection Manager. I am taking an emailAddress from a form and making a request to server to check if th
    Message 1 of 2 , Mar 31, 2007
    • 0 Attachment
      Hi folks,

      I'm trying to do the following with the YUI Connection Manager.

      I am taking an emailAddress from a form and making a request to server
      to check if th eemail address is already being used. If it is in use
      I'm sending an echo response as "Taken" and if it is not taken then
      the response is "Good".

      Problem I am having is I can't do a if(o.responseText == "Taken") { do
      this } else { do that };

      Can someone tell me what is wrong with my javascript?

      var div = document.getElementById('emailMSG');
      var emailDiv = document.getElementById('email');
      var oForm = document.getElementById('register');

      var handleSuccess = function(o){
      //var result = eval(o.responseText);
      div.innerHTML = "";
      if(o.responseText !== undefined){

      //if(result == "Taken"){
      //oForm.getElementById("emailMSG").style.backgroundColor = "red";
      div.style.backgroundColor = "red";
      div.innerHTML += "<li>This email address is already registered" +
      o.argument + "</li>";
      //}
      //else
      //{
      //}
      }
      };

      var handleFailure = function(o){
      if(o.responseText !== undefined){
      div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
      div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
      div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
      }
      };

      var callback =
      {
      success:handleSuccess,
      failure:handleFailure,
      };

      function makeRequest(){
      var sUrl = "checkEmail.php";
      var emailAddress = oForm.elements['emailAddress'].value;
      var postData = "emailAddress=" + emailAddress;

      var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback,
      postData);
      }
    • tssha
      ... ... Remove the trailing comma after failure:handleFailure so that the callback looks like this: var callback = { success:handleSuccess,
      Message 2 of 2 , Apr 2, 2007
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "smehrabi" <smehrabi@...> wrote:
        >
        > Hi folks,
        >
        > I'm trying to do the following with the YUI Connection Manager.
        >
        > I am taking an emailAddress from a form and making a request to server
        > to check if th eemail address is already being used. If it is in use
        > I'm sending an echo response as "Taken" and if it is not taken then
        > the response is "Good".
        >
        > Problem I am having is I can't do a if(o.responseText == "Taken") { do
        > this } else { do that };
        >
        > Can someone tell me what is wrong with my javascript?

        <snip>

        > var callback =
        > {
        > success:handleSuccess,
        > failure:handleFailure,
        > };

        Remove the trailing comma after "failure:handleFailure" so that the
        callback looks like this:

        var callback =
        {
        success:handleSuccess,
        failure:handleFailure
        };

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