• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Webserver - Ajax

 
Ranch Hand
Posts: 34
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Javad Rashidi
Ranch Hand
Posts: 34
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic