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

AutoComplete Questions

Expand Messages
  • dvidluca
    Hi, I ve got an autocomplete object that queries a mySQL database via XHR and PHP for words beginning with the character typed into the autocomplete. I works
    Message 1 of 2 , Dec 29, 2007
    View Source
    • 0 Attachment
      Hi,

      I've got an autocomplete object that queries a mySQL database via XHR
      and PHP for words beginning with the character typed into the
      autocomplete.

      I works fine, if I type 'a' in the autocomplete, I get a list of
      words beginning with 'a'.

      I want to extend it now and have set my PHP file to echo 'No matching
      data' if the parameter is not matched. Is there any way I can test
      for this string before showing the results div? I know I can get to
      the results via formatResult, but I don't want to have to reformat
      each result on a successful response.

      Also, I can't seem to get the dataErrorEvent working (although I can
      subscribe to dataReturnEvent easily enough), I've used the following
      code:

      var errorHandler = function() {
      alert("Error");
      }
      myACObj.dataErrorEvent.subscribe(ErrorHandler);

      I have also set a timeout on the datasource

      the alert never appears though (if I type a non-alphabetic character
      into the autocomplete for example), but I would have assumed that the
      timeout would stop the request, then (as no data had been received)
      the dataErrorEvent would fire (and then my alert display). Is the
      dataErrorEvent for, like, an actual error code from the server, or
      can no data be classed as a data error?
    • Alan Pinstein
      Two ideas: 1) From looking at the code; it seems that you should a different HTTP error code if you want dataErrorEvent to fire. 2) There are other events that
      Message 2 of 2 , Dec 30, 2007
      View Source
      • 0 Attachment
        Two ideas:

        1) From looking at the code; it seems that you should a different HTTP error code if you want dataErrorEvent to fire.
        2) There are other events that you can deal with as well; dataReturnEvent looks good.

        I think if I were you I'd return an empty set, subscribe to dataErrorEvent, and display your message in case this occurs.

        Your dataReturnEvent handler should essentially hide the "NO results" element if count > 0, or show it if count == 0.

        Alan

        On Dec 29, 2007, at 9:09 AM, dvidluca wrote:

        Hi,

        I've got an autocomplete object that queries a mySQL database via XHR 
        and PHP for words beginning with the character typed into the 
        autocomplete.

        I works fine, if I type 'a' in the autocomplete, I get a list of 
        words beginning with 'a'.

        I want to extend it now and have set my PHP file to echo 'No matching 
        data' if the parameter is not matched. Is there any way I can test 
        for this string before showing the results div? I know I can get to 
        the results via formatResult, but I don't want to have to reformat 
        each result on a successful response.

        Also, I can't seem to get the dataErrorEvent working (although I can 
        subscribe to dataReturnEvent easily enough), I've used the following 
        code:

        var errorHandler = function() {
        alert("Error" );
        }
        myACObj.dataErrorEv ent.subscribe( ErrorHandler) ;

        I have also set a timeout on the datasource

        the alert never appears though (if I type a non-alphabetic character 
        into the autocomplete for example), but I would have assumed that the 
        timeout would stop the request, then (as no data had been received) 
        the dataErrorEvent would fire (and then my alert display). Is the 
        dataErrorEvent for, like, an actual error code from the server, or 
        can no data be classed as a data error?


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