Back to my page

Developers


Update your widget’s content cleanly with Ajax

The Netvibes Ecosystem has its share of search widgets, mostly because they’re easy to build: make a test request in the original search site, write down the search URL, build it into a widget and make that widget open a new page with the search string neatly placed into the search URL.

This is nice, since easy+useful is nice. Yet, it has one pesky downside: it takes the user to a new page, rather than displaying the search result(s) in the widget. This is the whole point of Ajax: making the user experience seamless, by bringing the content into the page he is already in.

One recent widget manages to bring Ajax to its search in an elegant way: Maplin Catalog Search, by Tim Surtell. The way it works for the user is pretty straightforward:

…Type your request…

Mapling widget

…Wait for the results…

Mapling widget

…Page through the results…

Mapling widget

Behind the curtains, it’s still straightforward: being a Maplin affiliate for his Electronis in Meccano website, M. Sutrell had access to a data-feed of Maplin’s database. He only had to adapt that feed to output in JSON (thanks to an ASP script), and the hardest part was done. From there, the widget simply calls the ASP script with the getJson method:

var searchTerm = widget.body
  .getElementsByClassName("searchTerm")[0].value;
UWA.Data.getJson('http://www.surtella.com/maplin.asp?'
  + searchTerm, Maplin.display); 

The “Searching” animation has CSS display (visibility: visible;) and hide it (visibility: hidden;), and the JSON results are parsed through a loop into a table of results. The widget even uses the Pager control, for a more user-friendly parsing.

While it could be enhanced by replacing its hard-coded tables and cells by div-tags mixed with UWA’s Thumbnailed List template, the simple fact that M. Surtell told us he is more accustomed to coding in VB.Net than JavaScript, and is still able to build a widget this nice, is to us a testament of the ease-of-use of both JavaScript and our UWA methods.

Be Sociable, Share!

Tags: , , , , ,

3 Responses to “Update your widget’s content cleanly with Ajax”

  1. Ben Tremblay Says:

    Sidebar: Reliability.

    I use NetVibes a number of times a day.
    I have been using NetVibes daily for months.
    I had 12 very neatly configured tabs, with many many feeds, a number of notepads, and one main tab that included monitors for GMail accounts and POP3.

    Most of those 12 tabs are empty.
    All the widgets are gone.
    All those notepads are gone.

    Months of work … gone.

    0_o

    bdt

  2. François Says:

    Hello Ben, did you get my e-mail and my comment on your blog?

  3. Ben Tremblay Says:

    Francois – thanks for this; all is good here.
    I don’t know that your http://www.netvibes.com/?reset_cache=1 did the trick … I had earlier gone into my Firefox profile and deleted the contents of /cache, the most dramatically assertive action I could think of.

    In any case, I’m very glad to see my NetVibes service restored. Its functionality justifies the time I’ve invested in it.

    best to you all for ’08

Leave a Reply


Business

Our Widget Marketing solutions

Developers

Build once, run everywhere.

Community

Get involved, get localized.

Press

News. Media kits. Press releases.