I have a simple Ajax script that works perfectly fine in Chrome, Internet Explorer 8, Firefox 3.5.5 but fails in Firefox 3.5.7. The code is as follows:
HTML Page:
<div>
<form>
<input id='button' type='button' value='click'>
</form>
</div>
<script>
$(document).ready(function(){
$("#button").click(function(){
$.ajax({
type: "POST",
url: HTTP_HOST+"/ajax/ajax.php",
data: 'source=test',
dataType: 'html',
success: function(data) {alert('success: '+data);},
error: function(XMLHttpRequest, textStatus, errorThrown){alert('fail:\n'+
textStatus+'\n'+
errorThrown+'\n'
);}
});
});
});
</script>
ajax.php page:
$sourcePage = $_POST['source'];
if($sourcePage == 'test'){
echo 'hello';
}
I get the expected response (an alert box saying 'success: hello') in the browsers I mentioned above. In Firefox 3.5.7, however, I get the alert box with 'fail: error undefined'.
Using Firebug's Net panel I can see the Ajax calls and they get a response value of 200 OK although it can't seem to distinguish the size of the response.
There are no other errors according to Firebug.
Based on the apparently successful Ajax call and the undefined size of response, I'm assuming Firefox is having trouble interpreting the response though I'm new to this and have no idea what to try.
How can I solve this problem?