aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Java Webserver - Ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Java Webserver - Ajax" Watch "Java Webserver - Ajax" New topic
Author

Java Webserver - Ajax

Javad Rashidi
Ranch Hand

Joined: Feb 13, 2011
Posts: 34

I have created a simple webserver by java, when i request a file by url in browser for example http://127.0.0.1:9328/index.html it show page correctly but when i use Ajax it gave me nothing in fact xmlhttprequest.responseText is null. can anyone help me?


http://www.myviwo.com
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
Is the request being sent by the browser? Is it being received by the server? If so, is everything OK so far? What is sent back? Is that OK? if so, what is received by the browser?


Ping & DNS - updated with new look and Ping home screen widget
Javad Rashidi
Ranch Hand

Joined: Feb 13, 2011
Posts: 34

yes everything work fine, server sent back file with the http header 200 status code. i asked my question wrong, the right question is how to load page from different host by ajax. when i use http://127.0.0.1:9328/index.html by ajax it work but when i use http://example.com/index.html it doesn't work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Ajax cannot do that. For security purposes, an Ajax request must be made to the same server that served the page.

You can write a server-side proxy that handles the request, or, if the server supports it, you can try JSONP if all you are interested in is GET requests.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Webserver - Ajax
 
Similar Threads
Calling js(Ajax function) from html
Java Webserver
importance of container in webserver
Welcome Ryan Asleson and Nathaniel Schutta
access denied (SocketPermission 127.0.0.1:1099 connect,resolve)