This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Problems sending and receiving with XMLHttpRequest

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm having some problems both sending information to the backend (PHP) using POST, as well as successfully getting a response (if and when sending works).

I should preface everything by specifying that I'm working entirely in a local environment (using MAMP), which my research thus far indicates could be a contributing factor (?). Should also mention, along those lines, that I've modified my response script to accept status 0 as well as 200 (the former being an acceptable response when running in a local environment).

I've gotten to the point where I get the appropriate readyState and status responses, but there are issues in actually communicating with the PHP it seems.

First of all, here are my JS functions:



Instead of the "validate_user.php" destination indicated above, I first tried a simpler "hello_ajax.php" test:



With this, I was able to check that entries were successfully added to the "test" table. Also, the "pass" value being passed in was correct (from my html form that calls the ajax).

However, the echo'd message was not successfully received back in the "checkResponse" JS function - the alert was simply "Server says: " with no response text. That illustrated the receiving problem.

Now, consider "validate_user.php" instead of the hello_ajax function before:



With this, the database query at the start of the function is simply so I can check that we make it to that point - but we don't. In this case, it seems like we're not even getting into the PHP. I tried comparing this with the hello_ajax example but can't see any differences that would lead to this apparent breakdown in communication.

If anyone could help me out with any or all of these issues, I would appreciate it immensely!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!