We often get questions asked on Stack Overflow about sending mail and returning the response as JSON to a javascript function, including meaningful errors. For the experienced, it's easy to see how to separate these things into its separate parts, but it's hard for beginners, so we could do with an example they can use as a reference.
I'd recommend starting with one of the existing examples (such as the gmail one), converting it to produce JSON responses, and then write some Javascript to go with it.
Are you asking to provide some kind of confirmation whether mail is delivered or not ?
I am not able to understand the requirement. It would be great you post those stack overflow questions where users posted their queries. Please elaborate if possible.
No, that's a far more complex thing. What I'm suggesting is to provide an example which shows a request originating from a Javascript Ajax request (with and/or without jQuery), that is handled by PHP and uses PHPMailer to send a message using content supplied in the request, and then returns appropriate data (or an error) that can be handled correctly in JS. Perhaps start with the contact form example, but adapt it to send using JS rather than an HTML form submission.
I got your point. It's clear now. I will do it. Thanks for eloborating and for quick response.
An example of this kind of question popped up today.