Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:05:18+00:00 2026-06-07T03:05:18+00:00

I try to confirm that an email was sent with JSON and then cath

  • 0

I try to confirm that an email was sent with JSON and then cath the event with ajax and display a succes message on the screen.
The problem is that the email is not sent, and I get redirected to the “sended”:true because of the first part of the php script. The html and css is ok, I have tested it a lot.
What I actually want is to send the email with php and than use ajax to display a succes or error message. The problem is that I this is the first time that I use php and I just can’t find the correct way. I would not ask this, but I have to deliver the project by tonight and this is the last thing to be done.
You can check it in action at: http://webofdreams.ro/vworker/finemaid/finemaid.html# under email us link.

JS:

$ajax({
                     "type":"POST",
                     "url":"sendemail1.php",
                     "data": { name1: name1Val, emailFrom1: emailFrom1Val, comments: commentsVal},
                     "dataType":'json',
                     "success":function(response){
                         if (response.sended){
                            alert ("Mail Sended ok"); //Code after mail send
                           }else{
                            alert (response.error); //Code or allert on error
                           }
                          },                
                     error: function (xhr, ajaxOptions, thrownError){
                      alert(xhr.status+" "+thrownError);
                     }

php:

$send = @mail($mailTo, $subject, $message, "From: ".$mailFrom1); 
if ($send){
    echo mail($mailTo, $subject, $message, "From: ".$mailFrom1) ? '{"sended":true}':'{"sended":false,"error":"Mail send fail."}';
}else{
 echo '{"sended":false,"error":"Request Error."}';
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:05:19+00:00Added an answer on June 7, 2026 at 3:05 am

    Your ajax request is full of errors so i have wrote it from scratch, the below script will atleast take care of the ajax request.

            $(function(){
            name1Val = 'CaptureName';
            emailFrom1Val = 'CaptureEmail';
            commentsVal = 'CaptureComments';
            parameters = 'name1=' + name1Val + '&emailFrom1=' + emailFrom1Val + '&comments=' + commentsVal;
            $.ajax({
                type: "POST",
                url: "sendmail.php",
                data: parameters,
                error: function(response){
                    alert(response);
                },
                success: function(response){
                    alert(response);
                }
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the beforeunload event to get users to confirm that they want
I have an intermittent problem with some code that writes to a Windows Event
I'm using rails 2.3.5 and devise 1.0.6. I'm having users confirm account's with email.
I'm running on a 32-bit machine and I'm able to confirm that long values
I have a script that if user is uploading file and try to close
I'm trying to implement email confirmation using Pyramid framework. Here's the code that confirms
I want to confirm that my HomeController class is being selected by the route
I have an application that reads emails from ONE email account (gmail application account)
I was wondering if someone can confirm that App.Config file is cached by CLR
I've created a script that creates a new snapshot in a VM and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.