Please do not add this as an "answer" it's really an extension of the question.
You have at least two options:
Edit the question: You can always edit the question with additional information, and add a comment to the answer indicating that it hasn't resolved the issue.
Ask a new question: If the additional details you need to add are significant, or would change the focus of your original question, you can always ask a new question. You can include a link to the original question, plus whatever information would be necessary to provide detail on the second question.
Chat with the answerer: If you have enough reputation (or meet whatever other criteria would apply), you can invite the person who provided the answer that partially/almost worked to a chat. If you don't have sufficient reputation, but they may, you can ask them to start the chat. Or, pass enough info back and forth in the comments, and moving to a chat will be offered as an option. This gives you more options to directly communicate with the individual, and should allow more significant chunks of code to be exchanged.