| Author |
AJAX : How can I set response type other than 200 ("OK") in Server Response
|
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Hi all, From my servlet I'm setting i.e other than 200 ("OK") message ! But while checking at client side using AJAX like The alert stating "ERROR", is not executing ? Whats the problem ?
|
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
|
Because of the wonky formatting of your posted code (is that really how you write your code?) I can't tell what's going on. it looks like your alert is outside any conditional that checks the error code, so it should display always. If not, then you're not getting to that block of code at all.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Sorry for the formatting ! Here is AJAX 'call back handler' code else block at line 1 , is not executing , Im expecting it because , In my Server side Servlet action , I wrote So where I'm wrong ?
|
 |
Anirvan Majumdar
Ranch Hand
Joined: Feb 22, 2005
Posts: 261
|
|
You need to set the response status to something else other than 200 incase of an error. That should work in your case. PS: your code formatting is still awfully wonky. Bugs resulting from lack of proper indentation can give you awful nightmares in the future.
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Originally posted by Anirvan Majumdar: You need to set the response status to something else other than 200 incase of an error.
Ok, Thanks for the help ! I ll try !
Originally posted by Anirvan Majumdar: PS: your code formatting is still awfully wonky.
Can you please let me know whats the wonky thing about my above code ? I put only a part of code , which is of interest !
|
 |
Anirvan Majumdar
Ranch Hand
Joined: Feb 22, 2005
Posts: 261
|
|
Since you insist, let me try highlighting the issue with your indentation. This is how your code appears to be: ---------------------------------------- A much better way of writing the code above would be: ----------------------------- Now you might argue that there's not much to it, in which case, I guess there's nothing much to say. Putting in a little bit of effort to structure your code not only helps you minimise errors, but also helps those who try and go through the code to help you fix an error.
|
 |
 |
|
|
subject: AJAX : How can I set response type other than 200 ("OK") in Server Response
|
|
|