What should I do if I ask a question, and end up finding out that the answer is unrelated to what was discussed in the question body? For example, what if I ask a question about a script producing unexpected output, but I find out that everything in that script was OK, and the problem was with the servlet that sends the response? The servlet was never part of the question, and there is nothing wrong with the code mentioned in the question. What should I do? Should I answer the question and explain the scenario further? Or should I delete the whole question?
If the solution that you find might apply to someone else who searching for your question in the future, post it an accept it.
If the solution turns out to be entirely unique to your problem, I would delete the question (you can flag for a mod to delete if SO won't let you).