Ok so i have a campaign javascript that i need to get for a site. The site is under ssl and the campaign is not so the browser blocks the request
So to work around i am doing the request via the application_controller
before_filter :get_campaign
def get_campaign
uri = URI.parse("http://us1.campaign-archive1.com/generate-js/?u=2f77d2f8c77398c0b064223ba&fid=1&show=3")
begin
@campaign = Net::HTTP.get_response(uri).body
end
end
and in the view i do
%script{:language => "javascript", :type => "text/javascript"}
= @campaign.try(:html_safe)
because the @campaign is a document.write string...but for some reason its not writing....am i missing something or is there a better way to achieve this
UPDATE
After looking at the console in chrome i see this error Uncaught SyntaxError: Unexpected token <
Here is my generated code
<script language='javascript' type='text/javascript'>
document.write("<div class=\"display_archive\"><div class=\"campaign\">08\/29\/2012 - <a href=\"http:\/\/us1.campaign-archive1.com\/?u=2f77d2f8c77398c0b064223ba&id=4c4d33ed6f\" title=\"Ten Fun Facts and Figures from Gen Con Indy 2012\" target=\"_blank\">Ten Fun Facts and Figures from Gen Con Indy 2012<\/a><\/div><\/div>");
<br>
<div class='display_archive'></div>
<div class='campaign'>
Select
<a href='http://eepurl.com/jkmGT' target='_blank'>HERE</a>
to sign up for our newsletter!
</div>
</script>
@campaignis empty or not.