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
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
  • 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
  • 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

Send requsts to a php file using AJAX

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a html file, which has a Javascript section:

<html>
<header>
<script src="my_util.js" language="javascript"></script>
...
</header>

<body scroll="no" >
<script language="JavaScript" type="text/javascript">
<!--

//Somewhere in the JS code, I need to call http://www.XYZ.com/php/my.php

// -->
</script>
...

</body>
</html>

I can not change the file extension from html to php. How should I do it?
 
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:
  • Quote
  • Report post to moderator
I'm not savvy enough with the Apache web server (which is what I am assuming you are using to serve your php) to trick it into processing a file with a type .html instead of .php.
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it should belong to this forum.

I want to use Ajax to call the remote php file like following:

// I got XmlHttpRequest object successfully, but got an exception at the following line:
xmlHttpRequest.open('POST', "http://www.XYZ.com/php/my.php", true);

In FireFox, the exception was: 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 a Java object (servlet) in the same way, why not php?

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be clear, "www.xyz.com" is the server where your page was served from, right? Otherwise this access is not allowed under the "same origin" rule.
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Just to be clear, "www.xyz.com" is the server where your page was served from, right? Otherwise this access is not allowed under the "same origin" rule.


Yes. Both the html and php are from www.xyz.com. I can access the www.xyz.com/php/my.php directly from a browser w/o problems.
 
Bear Bibeault
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:
  • Quote
  • Report post to moderator
Ah, it was not clear that by "call" you meant an Ajax request. I've restored this to the HTML/JavaScript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you specifying a port, both using www? Everything about the urls have to be the same [ no sub domains]

Eric
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric. It is the "www".
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic