Hey guys, I''m trying to add Prototype.js to my website and am having some trouble getting started. My general call looks like this: new Ajax.Updater(div, url, {method: ''get'', onFailure: function() { alert(''AJax Failure''); } } ); When url is a local file in the same directory as the script, it works without problem, putting the entire contents of that file into the div. Works great. When I change the URL to anything else, say a photobucket picture, http://www.yahoo.com, whatever, nothing seems to happen. The failure event doesn''t fire and the div isn''t updated. What am I doing wrong? I think I''m close but I just can''t seem to get it to work. Thanks a lot for your help! Evan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You are seeing the security in JavaScript at work. You may not reach outside of your own domain to get content using JavaScript. So if you want to get stuff from another server, you will need to build a proxy in PHP or another dynamic language, and then pass the URL you want to get through that proxy. The Ajax request would be to your_proxy_script.php, and then you would pass the URL you wanted to retrieve as a parameter to the request: {parameters: "url=" + escape (theUrl)} In your proxy script, you would do whatever the language allowed you to, maybe this: $url = your_sanitizing_function($_POST[''url'']); echo file_get_contents(''http://'' . $url); Walter On Sep 12, 2007, at 11:56 AM, Evan Ruff wrote:> > Hey guys, > > I''m trying to add Prototype.js to my website and am having some > trouble getting started. My general call looks like this: > > new Ajax.Updater(div, url, {method: ''get'', onFailure: function() > { alert(''AJax Failure''); } } ); > > When url is a local file in the same directory as the script, it works > without problem, putting the entire contents of that file into the > div. Works great. > > When I change the URL to anything else, say a photobucket picture, > http://www.yahoo.com, whatever, nothing seems to happen. The failure > event doesn''t fire and the div isn''t updated. > > What am I doing wrong? I think I''m close but I just can''t seem to get > it to work. > > Thanks a lot for your help! > > Evan > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
trying to break one of the ground rules of Ajax No off-site requests. Use an iframe of a server-side code to get the content and then serve it. On 9/12/07, Evan Ruff <evan.ruff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hey guys, > > I''m trying to add Prototype.js to my website and am having some > trouble getting started. My general call looks like this: > > new Ajax.Updater(div, url, {method: ''get'', onFailure: function() > { alert(''AJax Failure''); } } ); > > When url is a local file in the same directory as the script, it works > without problem, putting the entire contents of that file into the > div. Works great. > > When I change the URL to anything else, say a photobucket picture, > http://www.yahoo.com, whatever, nothing seems to happen. The failure > event doesn''t fire and the div isn''t updated. > > What am I doing wrong? I think I''m close but I just can''t seem to get > it to work. > > Thanks a lot for your help! > > Evan > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
should be Use an iframe *or* server-side code to get the content and then serve it. On 9/12/07, Brian Williams <brianw1975-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > trying to break one of the ground rules of Ajax > > No off-site requests. > > Use an iframe of a server-side code to get the content and then serve it. > > > > On 9/12/07, Evan Ruff <evan.ruff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hey guys, > > > > I''m trying to add Prototype.js to my website and am having some > > trouble getting started. My general call looks like this: > > > > new Ajax.Updater(div, url, {method: ''get'', onFailure: function() > > { alert(''AJax Failure''); } } ); > > > > When url is a local file in the same directory as the script, it works > > without problem, putting the entire contents of that file into the > > div. Works great. > > > > When I change the URL to anything else, say a photobucket picture, > > http://www.yahoo.com, whatever, nothing seems to happen. The failure > > event doesn''t fire and the div isn''t updated. > > > > What am I doing wrong? I think I''m close but I just can''t seem to get > > it to work. > > > > Thanks a lot for your help! > > > > Evan > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ah haaaaaaaaa.... Should''ve known. Thanks guys! Evan On Sep 12, 1:01 pm, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> should be Use an iframe *or* server-side code to get the content and then > serve it. > > On 9/12/07, Brian Williams <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > trying to break one of the ground rules of Ajax > > > No off-site requests. > > > Use an iframe of a server-side code to get the content and then serve it. > > > On 9/12/07, Evan Ruff <evan.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hey guys, > > > > I''m trying to add Prototype.js to my website and am having some > > > trouble getting started. My general call looks like this: > > > > new Ajax.Updater(div, url, {method: ''get'', onFailure: function() > > > { alert(''AJax Failure''); } } ); > > > > When url is a local file in the same directory as the script, it works > > > without problem, putting the entire contents of that file into the > > > div. Works great. > > > > When I change the URL to anything else, say a photobucket picture, > > >http://www.yahoo.com, whatever, nothing seems to happen. The failure > > > event doesn''t fire and the div isn''t updated. > > > > What am I doing wrong? I think I''m close but I just can''t seem to get > > > it to work. > > > > Thanks a lot for your help! > > > > Evan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---