I'm currently trying to solve an odd problem. I always worked with ajax, json, etc but have no idea why that simple code below is not working.
Below is the full javascript and html code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<title>Testing Ajax</title>
</head>
<body>
<script>
$(function(){
$('h1').click(function(){
alert('clicked');
jQuery.ajax({
url: "teste2.html",
success: function(html){
$('h1').append(html);
},
error : function(){
alert('errou');
}
});
});
});
</script>
<h1>Json Funfando</h1>
</body>
</html>
At the same folder I have a file teste2.html. Anyway, if I rename the url to something that doesn't exist (dasdasdsadsa.html for example) that $.ajax will still return success, even with the correct name file the returned files are always empty. The error handling, if I inserted, is never called.
Anyone has any idea why this is happening?
PS.: I tryed to put it on a simple onload function, changing jQuery.ajax to $.ajax