Troubleshooting XML error returned to client browser
I'm new to Ajax. I'm getting a parse error in $.ajax. The xml file I am feeding it is dead simple, and validates just fine elsewhere. What else can I do to see what is wrong with the xml file?
Here's my problem function:
- $(document).ready(function(){
- $("#signup").submit(function(){
- alert("post is about to be called");
- $.ajax({
- url: "php/signup.php",
- type: "POST",
- datatype: "xml",
- data: {
- f_email: $("#f_email").val(),
- f_firstname: $("#f_firstname").val(),
- f_lastname: $("#f_lastname").val(),
- ...
- f_other: $("#f_other").val()
- },
- success: function(xml) {
- addMessages(xml);
- },
- error: function(httpreq,textstat,error_text) {
- alert(httpreq);
- alert(textstat);
- alert(error_text);
- addMessages(httpreq);
- }});
- return false;
- });
- });
The records make it out of the post function to the php/singup.php file. That file creates the records in the database and replies with this XML file (I have a function in signup.php that writes the xml output to a file after it sends it to the client):
- <?xml version="1.0"?>
- <response>
- <message>b</message>
- </response>
Yes, I'm literally just sending back the letter 'b' to signify success (on an updated record. 'a' signifies a new record and 'c' signifies an error inserting the sql.)
My PHP file has this header, which works on another page that also uses the $.ajax function:
- header("Content-type: text/xml");
When my $.ajax receives the xml file it triggers the error function. Those three alerts (lines 19-21) read:
[Object XMLHttpRequest]
parseerror
TypeError: Object required
How can I get more information about why $.ajax thinks that [Object XMLHttpRequest] is not an object?
Thank you!