Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
    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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Using AJAX to send a request to a remote php file

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

I want to use Ajax to send a request to a remote php file and I got XmlHttpRequest object successfully,
but got a exception at the following line:

xmlHttpRequest.open('POST', "http://www.XYZ.com/php/my.php", true);

In FireFox, the exception is: Access to restricted URI denied code: "1012"

I also tried IE and Safari and got a similar error at the same line of the code.

I know I can call remote Java object (servlet) in the same way, why not php?
 
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sounds like the browsers are rejecting an XSS (cross-site scripting) attack. Using AJAX to connect to a server other than the one the page came from is a no-no. At least that's what I think... I will move this post to the Javascript forum where people more knowledgeable than me hang out.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
JavaScript has a same domain policy, you can not interact with different domains. You need to look into using a serverside proxy.

Eric
 
Sheriff
Posts: 67637
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:
  • Report post to moderator
Please keep the conversation to within a single topic.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic