Hi,
I''m experiencing problems while trying to use Ajax (Ajax.Request,
Ajax.Updater) to connect to some Tomcat servlets. I''ve got a html
page, which code I attached below. This code triggers onException,
when URL in function greet() points to a servlet deployed on Tomcat.
As you can see I tried to ''debug'' the errors, but the alerts I
get
are : [t : Object object] and [e : object Error]. Furthermore, I can''t
see any logs in Tomcat, that a connection has been made. When I change
the URL to some php links on my local apache server, everything works
fine, onException is not triggered and the result is returned.
How could it be? I could understand exceptions, but why even a
connection to servlet url is not established?
Has anyone encountered similar problem? I also tried to connect to
some JBoss deployed servlet url and the exceptions are the same as for
Tomcat :/
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-2">
<title>Apex test</title>
<script src="js/prototype.js" type="text/javascript"
language="javascript"></script>
<script src="js/scriptaculous.js"
type="text/javascript"
language="javascript"></script>
<script type="text/javascript">
Event.observe(window, ''load'', init, false);
function init(){
$(''greeting-submit'').style.display =
''none'';
Event.observe(''greeting-name'', ''keyup'',
greet, false);
}
function greet(){
var url = ''http://127.0.0.1:19090/IDOPL/js'';
// var url = ''http://127.0.0.1:190/examples/servlets/servlet/
RequestInfoExample'';
var pars =
''greeting-name=''+escape($F(''greeting-name''));
window.alert(pars);
var target = ''greeting'';
var myAjax = new Ajax.Updater(target, url, { method: ''get'',
parameters: pars, onException : function(t,e) {window.alert(''t :
'' +
t);window.alert(''e : '' +e);} });
}
function ajax_response(originalRequest) {
window.alert(originalRequest.responseText);
// ajax_request(originalRequest.responseText, "");
}
</script>
</head>
<body>
<form method="get"
action="http://127.0.0.1:19090/IDOPL/js"
id="greeting-form">
<div>
<label for="greeting-name">Enter your
name:</label>
<input id="greeting-name" type="text"/>
<input id="greeting-submit" type="submit"
value="Greet
me!" />
</div>
<div id="greeting"></div>
</form>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I forgot to mention that I triple checked the URLs to servlets. They display in browser. There are also no firewalls involved. Regards, Luke --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try an HTTP debugger like this one (http://www.softx.org/debugger-download.html) to inspect both the request and the response to make sure those are what you expect. This sounds like maybe a SOP error though. Your ajax request must be to the same origin as the current page, i.e. http vs. https, domain name, and probably port as well. Try passing a relative URL rather than an absolute one. As for debug output, here is what I use to get details for Ajax requests and exceptions. http://pastie.caboo.se/52202 Colin lpk wrote:> I forgot to mention that I triple checked the URLs to servlets. They > display in browser. There are also no firewalls involved. > Regards, > Luke > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6 Kwi, 17:07, Colin Mollenhour <eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> Try an HTTP debugger like this one > (http://www.softx.org/debugger-download.html) to inspect both the > request and the response to make sure those are what you expect. This > sounds like maybe a SOP error though. Your ajax request must be to the > same origin as the current page, i.e. http vs. https, domain name, and > probably port as well. Try passing a relative URL rather than an > absolute one.Of course. How stupid am I ? :( I suppose it''s because of security reasons, that you can''t use ajax request to another origin? Anyway, I greatly appreciate your help. Regards, Luke --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---