On Jan 10, 11:49 pm, SkilliPedia <skillipe...@googlemail.com> wrote:
> I have a website where services, software,etc get reviewed. What i
> want to do is enable users to display reviews in their own websites as
> testimonials and as extra backlink for me.
>
> I am looking for  a js widget that can do that. My web application is
> coded in Java

I think doing this in jQuery would be a really heavy-weight solution.
Requiring your users to include jQ on their page just to add your
widget seems rather much, especially as this probably doesn't need to
do too much.  The example you point to formats everything server-side
as a single call to document.write().  That would probably be the
easiest approach.

That said, if you do choose to use jQuery, I suppose you can add it
yourself in your script, with something like this:

    var script = document.createElement("script");
    script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
jquery.min.js";
    script.type = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(script);

>From here you could request a JSONP call from your server in this
format:

    callbackName({"status": "ok", reviews: [{"rating": 7, "reviewer":
"Fred", "comments": "Loved it!"}, {/* etc */}]});

with code that looks like this:

    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?
tags=cat&tagmode=any&format=json&jcallback=?",
        function(data) {
            if (data.status == "ok") {
                $.each(data.reviews, function(i, review){
                    // do something with review
                });
            } else {
                // report error or ignore as you like
        }
    );

The trouble I see with doing it this way is that you will need hook
into the DOM on an arbitrary site, or proceed with additional
document.write statements in any case.  And if you have to do the
latter, why not simply format the server-side response as
document.write statements?

Good luck,

  -- Scott

Reply via email to