JavaScript retrieve external data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doubledutch
    New Member
    • Jul 2007
    • 3

    JavaScript retrieve external data

    Hi,

    I'm facing the following challenge. I am controlling a website on domain aaa (www.aaa.com) and one of the pages needs to use data which is retrieved from domain bbb (www.bbb.com).

    In pseudo code I would like my html page on www.aaa.com to do the following:

    while (forever) {
    my VarData = ReadURL("http://www.bbb.com");
    [Do something with VarData]
    sleep 5; // (and then try again...)
    }


    From various posts on this forum I seem to have concluded that using an hidden iframe is the best thing to do but I can't get it to work because, IE-7 gives me "access denied" errors every time I go to www.bbb.com using this code:

    var frame1=document .getElementById ('iFrameBBB');
    var iframeDocument = frame1.contentW indow ? frame1.contentW indow.document
    : frame1.contentD ocument;
    var root = iframeDocument. documentElement || iframeDocument. body;
    var HTML = root.innerHTML;


    and iFrameBBB is declared as:

    <iframe height="600" width="600" src="http://www.bbb.com" id='iFrameBBB' name='myiframe' >

    Can anyone suggest a simple method achieving the above? The data on www.bbb.com is a simple line of text.... Thanks in advance for your help

    Leon
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Use a server-side language instead to retrieve this information and then make AJAX requests to continuously get this information.

    Comment

    • doubledutch
      New Member
      • Jul 2007
      • 3

      #3
      Thanks for your reply but I don't think that's going to work.. Domain www.bbb.com uses client side cookies to determine how it will reply to requests so a server side script would not be able to retrieve these.... Is there any other technolgy I could use you think? Flash, VB / Active X, Java Applet? I don't really care what it is as long as it will work.

      Thanks

      Leon

      Comment

      • mrhoo
        Contributor
        • Jun 2006
        • 428

        #4
        Domain www.bbb.com uses client side cookies to determine how it will reply to requests
        Ajax calls usually need to be to and from the same domain.

        You have to have administer rights both domains to have permission to read from one and write to the other, with server code.

        Comment

        • doubledutch
          New Member
          • Jul 2007
          • 3

          #5
          Thanks. I seem to have tried every AJAX option now inclusive PHP-Proxy servers and it just doesn't work. If my research is correct - it appears that Flash is one of the few server side technologies which allows this so I guess I'll better find someone who can write this for me. I'll continue this discussion on the Flash forum!

          Comment

          • praveen2gupta
            New Member
            • May 2007
            • 200

            #6
            With Ajax and JavaScript you can not access outside your domain. Both works with in their Domain.I Think you need some server side Language to access the Data.

            Comment

            Working...