We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    With all of the AJAX talk going around I thought it was time to add some to my site. This snippet turns the FlexSearchForm snippet into an AJAX site search. The results from the search are loaded right in the page for the user. If the user does not have javascript enabled, the snippet will use the default searching of the FlexSearchForm snippet.

    The javascript code is based off of the example by Steve Smith of orderedlist.com.

    If you would like to see this in action you can go to my site here:

    http://www.muddydogpaws.com/notebook/ajax-search-snippet.html

    The instructions for installing and setting up this snippet are in the FSFAjax_readme.txt file in the zip.

    Enjoy,

    Kyle

    Updated: 05/18/2006 - I have added the code from Thomas (Shadock) to the main snippet to allow for live searching (i.e. results as you type). There is a new parameter that goes along with this. If you add the parameter &ajaxSearchType=`1` you will turn on the live search. I have also updated the scriptaculous effects to run in succession so the effects look better.

    Updated: 04/03/2006 - To make the search even better, I have added the search highlighting code from Marc (MadeMyDay). The updated code can be found in the download. You need to update all of the files excluding the images for this to work correctly.

    Updated: 03/20/2006 - After receiving some feedback I have modified the snippet a little. There is now a button that appears to close the search box after a search. Also I have made the snippet output the parameters set in the snippet to a bit of javascript so that I can use them in the ajax call. So you do not have to update the file ajaxSearch.php for your search settings. A thank you goes out to sottwell for these great ideas.

    *******Update: 03/19/06***********
    I added a button to close the seach box after you run the search. Great idea Susan. I have updated the zip here and on my site. The only file I had to change was the javascript file, so that is the only one you need to update.


    Mod note: File removed: ajaxSearch.zip (19.93 KB - downloaded 76 times.)
    Please visit the AjaxSearch Repository entry for downloads.
      • 6726
      • 7,075 Posts
      I just love the livesearch, very nice one !

      Just a problem : the archive above is corrupt can’t download it... Got it from your website though, and will try it tomorrow...

      Thanks a lot for this one grin
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 7923
        • 4,213 Posts
        Yes, great work again Kyle! I like it alot, and will definitely use. Thanks!


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 15987
          • 786 Posts
          I have updated the file for download above.
            • 10487 MODX Staff
            • 1,535 Posts
            Cool snippet! cool I will definitely give this one a try.
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 18397
              • 3,250 Posts
              That is waaaaaaaaay cooler than the Etomite one I ported a while back... (never released due to various issues)
                • 26435
                • 1,193 Posts
                I love it. Thanks for sharing this man. It is in use at my site now (see the sig). Very clever piece of scripting.

                -sD-
                scotty Delicious
                  Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                  All of the above... in no specific order.


                  I send pointless little messages
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Excellent! The only ’quibble’ I could have is that it would be nice to be able to close the boxes. Maybe a button with something like this:

                  onclick="Effect.Fade(this)"
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 15987
                    • 786 Posts
                    Quote from: sottwell at Mar 19, 2006, 12:04 AM

                    Excellent! The only ’quibble’ I could have is that it would be nice to be able to close the boxes. Maybe a button with something like this:

                    onclick="Effect.Fade(this)"


                    I have posted an updated version with this functionality included, great idea.
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      # Open ajaxSearch.php and set the options for your search.*

                      Hmm...is there perhaps some way the snippet could generate a bit of javascript that loads an array of these values into the javascript scope, then they could be passed via the AJAX call as params?
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org

                      This discussion is closed to further replies. Keep calm and carry on.