I had a simple form that used JQuery AJAX to call a PHP script and perform some work. This code worked properly for 2+ years and then all the sudden stopped working - and has some weird behavior I've having trouble debugging.
Here's the HTML code:
<div class="form-group">
<label for="commenter-name" class="col-sm-3">Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="commenter-name" id="commenter-name" placeholder="Enter Name" value="" >
</div>
</div>
<div class="form-group">
<label for="commenter-comment" class="col-sm-3">Comment</label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="commenter-comment" id="commenter-comment" placeholder="Enter Comment"></textarea>
</div>
</div>
<div class="clear"></div>
<div class="form-group custom-form">
<div class="col-sm-3"></div>
<div class="col-sm-9">
<input id="submit-comment" type="button" class="btn btn-success" value="Submit">
</div>
</div>
Here's the JS code (using JQuery 1.8.3):
$("#submit-comment").click(function(event) {
$.ajax({
type: "POST",
url: "_code/ProcessPoll.php",
data: { comment : comment, name : name, commenter_position : commenter_position }
})
});
Here's the PHP code:
if ($_POST["comment"])
{
//log results of the poll
$log = new PollsLogging($_POST["name"], $_POST["comment"], "comment", "comment", $_POST["commenter_position"]);
$log->WriteToFile();
}
This code worked effectively for 2+ years and now this is the behavior:
- Enter info in the textbox fields and hit the submit button
- The click event is triggered and then the JQuery AJAX call is made, but does not bring back a completion, success, or failure (I'm using the debugger in Chrome)
- Then I refresh the page and I am getting a status of 0 in the error from the AJAX (I don't have the debugging in here, but I just used this to figure it out: error: function(jqXHR, textStatus, errorThrown) {alert(jqXHR.status)}
Could something have changed in the different versions of all the major browsers for this to stop working? Am I blatantly missing something? I read a few things about the AJAX call might never be completing, but I'm not sure how to handle that... especially since I haven't made any code changes to this... I also have a few other small programs that are similar and those have also stopped working and are behaving in a similar way!
Any help/guidance is appreciated.
I'm sorry I can't comment because of my poor reputation, so I post this as an answer.
Actually, it's not possible to provide you an answer, we lack informations. I don't see any problem in the code you presented.
You're talking about a strange behaviour, can you describe it ? Did you tried to use a tool like Firebug to monitor your request headers ?