Jump to content

Sending a XML Request

LindaBB's Photo
Posted Dec 10 2010 08:14 AM
5697 Views

Hi,
I'm using the book Learning PHP, MySQL & Javascript trying to learn how to use the 3 languages together in a site I'm preparing for exams. Have a problem with the code-examples 18-6.xmlget.php and 18-7.xmlget.html from the book. I have copied directly, but still it doesn't load. I have put the php-part and the Ajax-part in the same php-file as you can see in the attached file.

Hope someone can help me, feel pretty foolish messing up with a book-example :blink:

Attached File  xmlget.php (1.81K)
Number of downloads: 532

Tags:
1 Subscribe


2 Replies

+ 1
  Robin Nixon's Photo
Posted Dec 10 2010 10:13 AM

Hi Linda,

Ajax communication between a web page and a web server suffers from very tight security restrictions. Data from the server will be accepted by the web page only if the page was loaded from the server.

Therefore the only way to properly test any Ajax code is to upload both the Web page and the PHP files to a web server (a local development server is not likely to work dues to useing localhost:// and a local file system), and test them from there.

In your example these are both one and the same file, but it must still be on a server with a domain.

I hope this helps.

- Robin.
 : Dec 10 2010 01:15 PM
Thanks a lot, Robin, I won't waste any more time on my localhost.