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

Simple xhr connection for autocomplete

Expand Messages
  • aricshelby
    I ve spent a day and a half trying to figure this out, and I m no dummy with JS. I am new to YUI, but it looks promising. So I followed the simple example for
    Message 1 of 4 , Mar 4, 2008
    • 0 Attachment
      I've spent a day and a half trying to figure this out, and I'm no
      dummy with JS.  I am new to YUI, but it looks promising.

      So I followed the simple example for connecting to a XHR source.  I
      have a php script that outputs xml like this: (consolidated of course)

      <?xml version="1.0" encoding="utf-8"?>
      <shipsearch>
      <ship mmsi="367053810" name="LYNNE MORAN   ">LYNNE MORAN   </ship>
      <ship mmsi="36011619" name="unknown  ">unknown   </ship>
      <ship mmsi="354264000" name="PANAM PACIFICO  ">PANAM PACIFICO </ship>
      </shipsearch>

      If I copy and paste this into an xml file, and use the XHR datasource
      to connect to it(test.xml), it works fine, all results get returned
      out course, because it's just spitting the same thing out no matter
      how many characters you enter.

      As soon as I go to the php script connection, I get nothing.  I've
      changed everything around so many times I'm looping in my head.  No
      errors are coming with FF or IE6/7.

      I have a suspicion that my problem lies in the query appendages for
      some reason, but I can not figure it out.  I have to include the query
      parameters, this data is coming from a joomla component I built, and
      it requires the params.   Hope someone can help.

      The full query string if anyone wants to check is:
      http://www.aisdatabase.com/index.php?option=com_shipsearch&format=raw&task=shipmmsi 

      if you add on  &query=3669  you will get a shorter list, and shorter with
      the more numbers you add, just like an autocomplete search.  :)

      Here is what I am doing on the simple html mock up page located at:

      http://www.aisdatabase.com/test.html 

          <h3>AIS Search:</h3>
          <div id="ysearchautocomplete">

              <input id="ysearchinput" type="text" name="p">
              <div id="ysearchcontainer"></div>
          </div>

      <script type="text/javascript">
      YAHOO.example.ACXml = new function(){
          this.oACDS = new YAHOO.widget.DS_XHR("index.php", ["ship", "mmsi"]);
          this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_XML;
          this.oACDS.queryMatchContains = true;
          this.oACDS.scriptQueryAppend = "option=com_shipsearch&format=raw&task=shipmmsi"; //Required params

          // Instantiate AutoComplete
          this.oAutoComp = new YAHOO.widget.AutoComplete("ysearchinput","ysearchcontainer", this.oACDS);
          
          // Stub for AutoComplete form validation
          this.validateForm = function() {
              // Validation code goes here
              return true;
          };
      };
      </script>

      Thank you for anyone that can help,

      Aric
    • Eric Miraglia
      Aric, It looks like you re not setting your Content-Type header to XML in your PHP file. Try putting this at the very top of the PHP: header( Content-Type:
      Message 2 of 4 , Mar 4, 2008
      • 0 Attachment
        Aric,

        It looks like you're not setting your Content-Type header to XML in your PHP file.  Try putting this at the very top of the PHP:

        header("Content-Type: text/xml");

        Regards,
        Eric


        On Mar 4, 2008, at 1:38 PM, aricshelby wrote:

        I've spent a day and a half trying to figure this out, and I'm no
        dummy with JS.  I am new to YUI, but it looks promising.

        So I followed the simple example for connecting to a XHR source.  I
        have a php script that outputs xml like this: (consolidated of course)

        <?xml version="1.0" encoding="utf- 8"?>
        <shipsearch>
        <ship mmsi="367053810" name="LYNNE MORAN   ">LYNNE MORAN   </ship>
        <ship mmsi="36011619" name="unknown  ">unknown   </ship>
        <ship mmsi="354264000" name="PANAM PACIFICO  ">PANAM PACIFICO </ship>
        </shipsearch>

        If I copy and paste this into an xml file, and use the XHR datasource
        to connect to it(test.xml) , it works fine, all results get returned
        out course, because it's just spitting the same thing out no matter
        how many characters you enter.

        As soon as I go to the php script connection , I get nothing.  I've
        changed everything around so many times I'm looping in my head.  No
        errors are coming with FF or IE6/7.

        I have a suspicion that my problem lies in the query appendages for
        some reason, but I can not figure it out.  I have to include the query
        parameters, this data is coming from a joomla component I built, and
        it requires the params.   Hope someone can help.

        The full query string if anyone wants to check is:
        http://www.aisdatab ase.com/index. php?option= com_shipsearch&format=raw&task=shipmmsi 

        if you add on  &query=3669  you will get a shorter list, and shorter with
        the more numbers you add, just like an autocomplete search.   :)

        Here is what I am doing on the simple html mock up page located at:

        http://www.aisdatab ase.com/test. html  

            <h3>AIS Search:</h3>
            <div id="ysearchautocomp lete">

                <input id="ysearchinput" type="text" name="p">
                <div id="ysearchcontaine r"></div>
            </div>

        <script type="text/javascri pt">
        YAHOO.example. ACXml = new function(){
            this.oACDS = new YAHOO.widget. DS_XHR("index.php", ["ship", "mmsi"]);
            this.oACDS.response Type = YAHOO.widget. DS_XHR.TYPE_ XML;
            this.oACDS.queryMat chContains = true;
            this.oACDS.scri ptQu eryAppend = "option=com_shipsear ch&format=raw&task=shipmmsi"; //Required params

            // Instantiate AutoComplete
            this.oAutoComp = new YAHOO.widget. AutoComplete( "ysearchinput" ,"ysearchcontain er", this.oACDS);
            
            // Stub for AutoComplete form validation
            this.validateForm = function() {
                // Validation code goes here
                return true;
            };
        };
        </script>

        Thank you for anyone that can help, 

        Aric


      • Aric Shelby
        Thanks, I ve abandoned YUI. Mootools is just much simpler for what I need. YUI is overkill for my app right now, and I still may use a couple of things from
        Message 3 of 4 , Mar 4, 2008
        • 0 Attachment
          Thanks, I've abandoned YUI.  Mootools is just much simpler for what I need.

          YUI is overkill for my app right now, and I still may use a couple of things from YUI.

          Thank you for checking on this.  I had tried it both ways, with no luck.  If I looked at just the XML file, after saving the output from the php.  It worked fine, with or without the header.

          It's probably me, but I need something that just works, and YUI didn't do it for me.

          Thanks again


          ----- Original Message ----
          From: Eric Miraglia <miraglia@...>
          To: ydn-javascript@yahoogroups.com
          Sent: Tuesday, March 4, 2008 9:54:29 PM
          Subject: Re: [ydn-javascript] Simple xhr connection for autocomplete

          Aric,


          It looks like you're not setting your Content-Type header to XML in your PHP file.  Try putting this at the very top of the PHP:

          header("Content- Type: text/xml");

          Regards,
          Eric


          On Mar 4, 2008, at 1:38 PM, aricshelby wrote:

          I've spent a day and a half trying to figure this out, and I'm no
          dummy with JS.  I am new to YUI, but it looks promising.

          So I followed the simple example for connecting to a XHR source.  I
          have a php script that outputs xml like this: (consolidated of course)

          <?xml version="1.0" encoding="utf- 8"?>
          <shipsearch>
          <ship mmsi="367053810" name="LYNNE MORAN   ">LYNNE MORAN   </ship>
          <ship mmsi="36011619" name="unknown  ">unknown   </ship>
          <ship mmsi="354264000" name="PANAM PACIFICO  ">PANAM PACIFICO </ship>
          </shipsearch>

          If I copy and paste this into an xml file, and use the XHR datasource
          to connect to it(test.xml) , it works fine, all results get returned
          out course, because it's just spitting the same thing out no matter
          how many characters you enter.

          As soon as I go to the php script connection , I get nothing.  I've
          changed everything around so many times I'm looping in my head.  No
          errors are coming with FF or IE6/7.

          I have a suspicion that my problem lies in the query appendages for
          some reason, but I can not figure it out.  I have to include the query
          parameters, this data is coming from a joomla component I built, and
          it requires the params.   Hope someone can help.

          The full query string if anyone wants to check is:
          http://www.aisdatab ase.com/index. php?option= com_shipsearch&format=raw&task=shipmmsi 

          if you add on  &query=3669  you will get a shorter list, and shorter with
          the more numbers you add, just like an autocomplete search.   :)

          Here is what I am doing on the simple html mock up page located at:

          http://www.aisdatab ase.com/test. html  

              <h3>AIS Search:</h3>
              <div id="ysearchautocomp lete">

                  <input id="ysearchinput" type="text" name="p">
                  <div id="ysearchcontaine r"></div>
              </div>

          <script type="text/javascri pt">
          YAHOO.example. ACXml = new function(){
              this.oACDS = new YAHOO.widget. DS_XHR("index.php", ["ship", "mmsi"]);
              this.oACDS.response Type = YAHOO.widget. DS_XHR.TYPE_ XML;
              this.oACDS.queryMat chContains = true;
              this.oACDS.scri ptQu eryAppend = "option=com_shipsear ch&format=raw&task=shipmmsi"; //Required params

              // Instantiate AutoComplete
              this.oAutoComp = new YAHOO.widget. AutoComplete( "ysearchinput" ,"ysearchcontain er", this.oACDS);
              
              // Stub for AutoComplete form validation
              this.validateForm = function() {
                  // Validation code goes here
                  return true;
              };
          };
          </script>

          Thank you for anyone that can help, 

          Aric





          Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
        • Eric Miraglia
          Aric, Very sorry to hear we lost your business on this, but if you found something better suited to your needs, then that s all to the good. When I looked at
          Message 4 of 4 , Mar 4, 2008
          • 0 Attachment
            Aric,

            Very sorry to hear we lost your business on this, but if you found something better suited to your needs, then that's all to the good.  

            When I looked at your XML feed (as served by PHP), it was serving with the following header:

            Content-Type text/html; charset=utf-8

            That header is going to prevent you from getting the results you're hoping for with an XML-based data source in the YUI world.

            In any case, best of luck with your project, and we hope to see you back here for a second chance with YUI down the road.

            Regards,
            Eric


            ______________________________________________
            Eric Miraglia
            Yahoo! User Interface Library



            On Mar 4, 2008, at 8:08 PM, Aric Shelby wrote:


            Thanks, I've abandoned YUI.  Mootools is just much simpler for what I need.

            YUI is overkill for my app right now, and I still may use a couple of things from YUI.

            Thank you for checking on this.  I had tried it both ways, with no luck.  If I looked at just the XML file, after saving the output from the php.  It worked fine, with or without the header.

            It's probably me, but I need something that just works, and YUI didn't do it for me.

            Thanks again


            ----- Original Message ----
            From: Eric Miraglia <miraglia@yahoo- inc.com>
            To: ydn-javascript@ yahoogroups. com
            Sent: Tuesday, March 4, 2008 9:54:29 PM
            Subject: Re: [ydn-javascript] Simple xhr connection for autocomplete

            Aric,


            It looks like you're not setting your Content-Type header to XML in your PHP file.  Try putting this at the very top of the PHP:

            header("Content- Type: text/xml");

            Regards,
            Eric


            On Mar 4, 2008, at 1:38 PM, aricshelby wrote:

            I've spent a day and a half trying to figure this out, and I'm no
            dummy with JS.  I am new to YUI, but it looks promising.

            So I followed the simple example for connecting to a XHR source.  I
            have a php script that outputs xml like this: (consolidated of course)

            <?xml version="1.0" encoding="utf- 8"?>
            <shipsearch>
            <ship mmsi="367053810" name="LYNNE MORAN   ">LYNNE MORAN   </ship>
            <ship mmsi="36011619" name="unknown  ">unknown   </ship>
            <ship mmsi="354264000" name="PANAM PACIFICO  ">PANAM PACIFICO </ship>
            </shipsearch>

            If I copy and paste this into an xml file, and use the XHR datasource
            to connect to it(test.xml) , it works fine, all results get returned
            out course, because it's just spitting the same thing out no matter
            how many characters you enter.

            As soon as I go to the php script connection , I get nothing.  I've
            changed everything around so many times I'm looping in my head.  No
            errors are coming with FF or IE6/7.

            I have a suspicion that my problem lies in the query appendages for
            some reason, but I can not figure it out.  I have to include the query
            parameters, this data is coming from a joomla component I built, and
            it requires the params.   Hope someone can help.

            The full query string if anyone wants to check is:
            http://www.aisdatab ase.com/index. php?option= com_shipsearch&format=raw&task=shipmmsi 

            if you add on  &query=3669  you will get a shorter list, and shorter with
            the more numbers you add, just like an autocomplete search.   :)

            Here is what I am doing on the simple html mock up page located at:

            http://www.aisdatab ase.com/test. html  

                <h3>AIS Search:</h3>
                <div id="ysearchautocomp lete">

                    <input id="ysearchinput" type="text" name="p">
                    <div id="ysearchcontaine r"></div>
                </div>

            <script type="text/javascri pt">
            YAHOO.example. ACXml = new function(){
                this.oACDS = new YAHOO.widget. DS_XHR("index.php", ["ship", "mmsi"]);
                this.oACDS.response Type = YAHOO.widget. DS_XHR.TYPE_ XML;
                this.oACDS.queryMat chContains = true;
                this.oACDS.scri ptQu eryAppend = "option=com_shipsear ch&format=raw&task=shipmmsi"; //Required params

                // Instantiate AutoComplete
                this.oAutoComp = new YAHOO.widget. AutoComplete( "ysearchinput" ,"ysearchcontain er", this.oACDS);
                
                // Stub for AutoComplete form validation
                this.validateForm = function() {
                    // Validation code goes here
                    return true;
                };
            };
            </script>

            Thank you for anyone that can help, 

            Aric





            Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


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