Created
April 7, 2011 20:18
-
-
Save jboesch/908624 to your computer and use it in GitHub Desktop.
jQuery's complete is not being called when I have 400 headers set... weird.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* So it seems my "complete" callback is never called when I have a header of 400 or 404 set. Any ideas? | |
*/ | |
// My PHP file.. | |
header("Content-Type: application/json"); | |
header('HTTP/1.1 400 Bad Request'); | |
$response = array( | |
'status' => 'error', | |
'message' => 'You need to set the $response var.' | |
); | |
echo json_encode($response); // produces valid JSON: {"status":"error","message":"You need to set the $response var."} | |
// My JS | |
$.ajax({ | |
url: href, | |
dataType: 'json', | |
complete: function(){ | |
console.log('this is NEVER called so long as i have a 400 header'); | |
}, | |
success: function(){ | |
console.log('blah') | |
}, | |
error: function(){ | |
console.log('this is called when my header is 400. this works!') | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment