• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 616
  • Last Modified:

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
0
doctor069
Asked:
doctor069
  • 6
  • 4
  • 4
3 Solutions
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now