Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problems sending and receiving with XMLHttpRequest

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!
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic