views:

791

answers:

4

I have been developing a service that allows users to insert information from my database onto their sites by using iframes. The only problem was that the iframe needs to be resizeable and this is one of the biggest problems with iframes as most people already know, aswell as the fact I can access objects on the parent page from within the iframe and vice versa.

I have thought of making an asp.net web servie to server up the HTML and access it by using a get request. However this also has a problem since these request can only be made from the same domain?

What I need to know is the best way to retrieve a small piece of HTML containing customer reviews from server and display it on their page using some sort of AJAX.

Thanks

A: 

I think the jQuery library might be what you need - specifically, look into jQuery Ajax.

Tomas Lycken
I have tried using jquery but it only works with same domain. Otherwise it would work just perfectly
The_Lorax
+1  A: 

Your question is a duplicate of this one.

cdonner
Yup thats pretty much what I wanted to do. Thanks for giving me the link.
The_Lorax
+1  A: 

if your users can add a < script > line to their site pointing to code on your site, you can fairly easily offer a mechanism to build a floating (and resizable) DIV on their page that you jquery.load() with content from your site ...

example: "To use my service on your site, add the following line to your < head >"

<script type='text/javascript' src='http://mysite.com/scripts/dataget.js />

then add a link or button anywhere and give it a class 'get-date-from-mysite'

< input type='button' value='Click to see the data' class='get-data-from-mysite' />

--

Then in that script you do (something like):

$(function() {
    $('.get-data-from-mysite').click(function() {
        $('body').append("<div id='mydiv' 'style=position:absolute; z-index:999; left:                 ...

        $('#mydiv').load(' .... // url that sends html for content
    });
   ...etc

resize-able div stuff needs to be added too

Scott Evernden
A: 

Following on what Scott Evernden is explaining, you can add a <script> tag such as:

<script id="my_script_tag" type='text/javascript' src='http://mysite.com/scripts/dataget.js' />

Inside dataget.js you can simply reference the script tag itself by using its "id" (document.getElementById("my_script_tag");) and replace it (insertBefore()) with relevant data.

To get the data from your server you can use JSONP (lots of stuff on SO as well), which is an ajax technique for cross-domain communication.

Luca Matteis