07 Apr 2008
Hi all,
I'm running my zoop ajax app in test and mode dumping errors to the zoop error log. What I'd really like to do is have zoop or php itself return a different HTTP status code when an error occurs that's written to the log. Reason being, I need to have prototype do a different callback when an error occurs. Is there a facility to do this in Zoop or php?
thanks,
Jeremy
AJAX errors
PHP has a function for modifying http headers.
header("HTTP/1.0 404 Not Found");
However, it might be better to do:
pageAjaxRequest():
if($error) echo json_encode(array('response' => 'error', 'content' => $error)); else echo json_encode(array('response' => 'success', 'content' => $someHTMLResponse));myPage.js:
function myCallback(response) { div = document.getElementById('myElement'); if(response.response == 'error') errorCallback(); else if(response.response == 'success') div.innerHTML = response.content; }since sending an HTTP error is a little misleading.
This depends on using json as the data transfer protocol, and of course, my callbacks are not correct, they're just to give you an idea of what can work.