is it true that XMLHTTPrequest is not Cross Domain? Cannot request response from other sites??
On Tue, Oct 7, 2008 at 7:05 PM, mdipierro <[EMAIL PROTECTED]> wrote: > > The equivalent of this > > <?php echo "This is the text from the server"; ?> > > in web2py is > > def index(): > return "This is the text from the server:" > > Not quite what you have. Are the two example running on the same > client. I believe the JS code you have only works on IE. > I suggest you use the jQuery.ajax function or web2py ajax function. > > Massimo > > > On Oct 7, 12:53 pm, "Phyo Arkar" <[EMAIL PROTECTED]> wrote: > > Dear Massimo; > > > > I am trying to get web2py's response from an Ajax Javascript hosted in my > > friend's PC. > > > > He have PHP file hosted in his own pc and he try to get the response from > > php file via the ajax script > > > > it worked well for him > > > > But for response from web2py , it do not work.. we have been testing and > i > > cant find out anything as normally running both php and web2py , there is > no > > changes in output at alll. > > > > Is that web2py fault due to session saving? I did session.forget but > there > > is no changes , it still session in header. > > > > *Web2py /application/controllers/default.py:* > > > > session.forget() ## uncomment if you do not need sessions > > > > def index(): > > > > return dict(message="This is the text from the server:" ) > > * > > php.php , hosted on his Apache server:* > > > > <?php > > echo "This is the text from the server"; > > ?> > > > > * > > ajaxtest_php.html :* *Ajax Test for php* > > > > <html> > > <head> > > <title>My Ajax Application</title> > > <script Language="JavaScript"> > > function getXMLHTTPRequest() { > > try { > > req = new XMLHttpRequest();} catch(err1) { > > > > try { > > req = new ActiveXObject("Msxml2.XMLHTTP"); > > } catch (err2) { > > try { > > req = new ActiveXObject("Microsoft.XMLHTTP"); > > } catch (err3) { > > req = false; > > } > > } > > > > } > > return req; > > } > > > > var http = getXMLHTTPRequest(); > > > > function getServerText() { > > var myurl = 'http://localhost/php.php'; > > > > http.open("GET", myurl, true); > > http.onreadystatechange = useHttpResponse; > > http.send(null); > > > > } > > > > function useHttpResponse() { > > if (http.readyState == 4) { > > if(http.status == 200) { > > var mytext = http.responseText; > > document.getElementById('myPageElement').innerHTML = mytext; > > } > > } else { > > document. getElementById('myPageElement').innerHTML = ""; > > } > > > > } > > > > </script> > > </head> > > <body onLoad="getServerText()"> > > Here is the text returned by the server:<br> > > <div id="myPageElement"></div> > > </body> > > > > * > > ajaxtest_w2p.html : Ajax Test for web2py > > > > *<html> > > <head> > > <title>My Ajax Application</title> > > <script Language="JavaScript"> > > function getXMLHTTPRequest() { > > try { > > req = new XMLHttpRequest();} catch(err1) { > > > > try { > > req = new ActiveXObject("Msxml2.XMLHTTP"); > > } catch (err2) { > > try { > > req = new ActiveXObject("Microsoft.XMLHTTP"); > > } catch (err3) { > > req = false; > > } > > } > > > > } > > return req; > > } > > > > var http = getXMLHTTPRequest(); > > > > function getServerText() { > > var myurl = 'http://192.168.0.2:9090/ajax/default/index; > > > > http.open("GET", myurl, true); > > http.onreadystatechange = useHttpResponse; > > http.send(null); > > > > } > > > > function useHttpResponse() { > > if (http.readyState == 4) { > > if(http.status == 200) { > > var mytext = http.responseText; > > document.getElementById('myPageElement').innerHTML = mytext; > > } > > } else { > > document. getElementById('myPageElement').innerHTML = ""; > > } > > > > } > > > > </script> > > </head> > > <body onLoad="getServerText()"> > > Here is the text returned by the server:<br> > > <div id="myPageElement"></div> > > </body> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---