jquery load from amazon s3

Is it possible to have html files on amazon s3 and use jquery.load('http://amazonurl/test.html) into a div on the page

I tried and the html does not load onto the page

Firebug says it loaded ok but does not show html...

Thanks in advance
doctor069Asked:
Who is Participating?
 
Greg AlexanderLead DeveloperCommented:
Browsers/Servers will not allow cross site scripting... you could file_get_contents() with PHP is that is an option?
0
 
doctor069Author Commented:
Thanks my guess was it was a cross domain issue. unfortunately it is straight html no back end server
0
 
Greg AlexanderLead DeveloperCommented:
You are correct... glad to help
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
leakim971PluritechnicianCommented:
0
 
Greg AlexanderLead DeveloperCommented:
Wow, I stand corrected!
0
 
leakim971PluritechnicianCommented:
Not really @galexander07, not really ;-)

YQL is something like an online proxy by Yahoo!
It allow you to convert (change format) of the data too
0
 
leakim971PluritechnicianCommented:
by "online" I mean "not your own"
0
 
Greg AlexanderLead DeveloperCommented:
@leakim971 Ahhh I see now
0
 
doctor069Author Commented:
Tried http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/ but could not get it to work

I was thinking... is it possible to wrap the html code (just a div and some text) in a jsonp and return it

Just not sure how to do it...if its even possible without server side code...
0
 
leakim971PluritechnicianCommented:
could you provide your amazon s3 url
0
 
doctor069Author Commented:
just playing with it now...

http://a172e321.s3.amazonaws.com/1.html
0
 
doctor069Author Commented:
got it!

  var surl = "http://a172e321.s3.amazonaws.com/1.html";

        $.ajax({
            url: surl,
            dataType: "jsonp",
            jsonp: "tester",
            jsonpCallback: "tester",
            success: function(rdata) {
                var aaa = rdata.body
               $('#insertdiv').append(aaa);
            },
            error: function(rdata) {
                alert('Error' + rdata);
            }
        });


tester({"body":"Cat, dog, turtle, hamster, parrot\n"})
0
 
doctor069Author Commented:
One more note for anyone who was to try this:

you need to use encodeURIComponent and decodeURIComponent to have the html render properly.

In hindsight I don't think it is worth all the trouble. Especially if you html changes often... encoding and removing white space makes the html  impossible to read. Remember: don't use with secure data!

There are some advantages. Mostly taking as much load as possible off your server and using amazon to do the work.

But it does work and the techie in me likes that part!

0
 
doctor069Author Commented:
Thanks everyone for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.