I suggest you provide your service using JSONP instead of ad hoc JavaScript
code. That way it will work with the native JSONP support in jQuery and
other libraries.

To do this, you need to accept a parameter in your service URL that
specifies a callback function name, and you generate the output using that
name as a JavaScript function call. For example, suppose you use callback=
for this, and format=jsonp to specify the JSONP output. (This way you could
offer additional formats such as XML or straight JSON if you want.)

Then the jQuery code might look like:

    $.getJSON(
        'http://example.com/service?format=json&callback=?',
        function( json ) {
            alert( json.test );
        }
    );

jQuery will replace the ? at the end of that URL with a generated function
name, so the final URL might look like:

    http://example.com/service?format=json&callback=json1234

And the data you return would look like:

    json1234({"test":"abc"})

-Mike

> From: freebeme
> 
> Hello,
> 
> I provide a web service. I've hacked out a way using jquery 
> and dynamic script loading that enables people to embed the 
> service directly into their web pages. Basically my web 
> service responds with content type javascript and sends the  
> html  as a javascript variable.
> 
> An analogy of the web service is a guestbook and my users can 
> now plonk the guestbook directly into their web page.
> 
> However before releasing it for people to try out I want to 
> find out if I'm asking for trouble? Is this a common 
> technique that is used?
> Are there security issues that I haven't thought about. Would 
> I get detected by the likes of google as potentially being up 
> to no good etc etc.
> 
> thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to