Posts Tagged ‘SpryURLUtils.js’

Using SPRY to fetch values from a URL

And then filter an XML file based on the values passed from the URL.

If you’re not aware, Adobe now has it’s own AJAX/Javascript library called SPRY for you to use and better yet they include this with Dreamweaver CS3. I assume that you already probably know of or use SPRY.

So lets assume you want to pass in a value via your URL to filter your data set, baring in mind that this will be a destructive filter. So for example your url is mysite.com/index.htm?myFilter=a

And for example your XML file is something like;

description description

For this to work you need to add in/ include these JavaScript files in your HTML file:



// These are needed to interface with the XML file

// This is whats used to get the values from the URL query string

And this is the code, if you’ve already used SPRY then you’ll understand some of this.

And now when you make your call to the data set as normal, it will still function, but when a value is passed into the myFilter variable in the URL, it will then filter the data and return only the matching results.

More can be found here from Adobe