Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
cannot get a response ajax problem
Old 06-24-2009, 03:32 PM cannot get a response ajax problem
Hank Scorpio's Avatar
Novice Talker

Posts: 11
Name: Hank Scorpio
Trades: 0
Hi All

I have been looking at ajax for the first time lately, and whilst I thought I got the concept, I can't get this bloody thing to work.

I went through the tutorial at W3 schools http://www.w3schools.com/php/php_ajax_responsexml.asp

It seemed fairly straight forward, so I modified it slightly for my own purposes. I could not get it to work at all, it did not return any XML at all. After 4 hours of pulling out my hair, I thought I will copy the exact version from W3 schools and replicate the database locally.

It did not work. So then I have looked into everything I could think off, but to no avail.

I am using a WAMP setup on my system. With regards to my modifications, I basically have 4 records in a database table. The PHP script pulls them from a database, and using an onclick event call, fires off the javascript. The rest (the ajax code, and the PHP page that creates the XML) are the exact same as the W3 example.

I have used an alert box after the xmlhttp.open("GET", url, true) part of the code, and it does have the url as I would expect it to be (for instance clicking on link 1 that I pulled from the database on the PHP page gives me responseXML.php?q=1, or link 2 gives repsonseXML.php?q=2 etc......).

It seems like it does not then get read in the $q=$_GET['q'] part of the PHP page (responseXML.php). If I open up responseXML.php and hard code a value to the $q variable it will produce XML data displayed to this page.

I keep thinking maybe the XML document wasn't well enough formed, but surely then it wouldn't have worked with hardcoded variables? I have also read about headers with content type of text/xml, I have tried implementing these from examples shown but again no joy.

When I tried the W3 version with responseText instead of the responseXML version it worked fine. Does anybody out there have any idea's what I am doing wrong?

I hope I have explained this well enough, I am going nuts trying to figure this out.

Many Thanks

Hank Scorpio
Hank Scorpio is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to cannot get a response ajax problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47055 seconds with 12 queries