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

  • SEARCH
  • Home
  • 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 7458185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:24:57+00:00 2026-05-29T13:24:57+00:00

on the call back after the ajax call in qm150_submit $.post …. I want

  • 0

on the call back after the ajax call in qm150_submit $.post ….
I want to call a second function called ‘send_email’ (which also has a callback called ‘success_callback’

I am getting an error here

function () {send_email(fromName,fromEmail,toEmail,subject,message,success_callback) };

error: Uncaught SyntaxError: Unexpected token )

here is the code :

function qm150_submit($title, $name, $email, $description, $send_email) {

  $.post('<?PHP print API_SUBMIT; ?>', { "title": $title, "name": $name, "email": $email, "description": $description },
    function (data) {          // callback function after API_SUBMIT

    // Send email with a link to their collection
      if ($send_email) {

        // parameters for the send_email() ajax function

        var subject = "subject";
        var collection_id = data.collection_id;  // data is json returned from the ajax above
        var toEmail = $email
        var message = "<?PHP print SHARE_COLLECTION;?>"+collection_id;
        var fromEmail = "<?PHP print EMAIL_FROM_EMAIL; ?>";
        var fromName = "<?PHP print EMAIL_FROM_NAME; ?>";

        var success_callback = function (results) { 
          alert('send_email has returned with: '+results);
        };

        alert('I am now calling the send_email');
        function () {send_email(fromName,fromEmail,toEmail,subject,message,success_callback) };

      }
    });
        // missing a curly bracket ? no! note  double indentation of the anonymous function (data) is a continuation of first statement
}

edit: and the code for the send_email()

function send_email(fromName,fromEmail,toEmail,subject,message,success_callback) {
  alert('send_email called');
  $.ajax({
    type: 'post',
    url: '<?PHP print API_SHARE_EMAIL;?>',
    data: 'fromName=' + fromName + '&fromEmail=' + fromEmail + '&toEmail=' + toEmail + '&subject=' + subject + '&message=' + message,
    dataType:'json',
    success: success_callback
  });
  alert('send_email finished');
  return true;
}
  • 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-05-29T13:24:57+00:00Added an answer on May 29, 2026 at 1:24 pm

    The unexpected token is the ( after function.

    First of all, you’re declaring an anonymous function without ever calling it. Secondly, an anonymous function declaration cannot be a statement (or in other words, a function statement must have a name), which is why the ( is unexpected (javascript expects a function name, not parantheses).

    Simply call send_email directly… It’s already inside a function, so it won’t “pollute” the global object (there’s nothing to pollute it with anyway) – I see no need for an anonymous function:

    alert('I am now calling the send_email for real!');
    send_email(fromName, fromEmail, toEmail, subject, message, success_callback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so im trying to start an ajax call after the first call has
i have the following code and the call back function is not being called
I have a function for an ajax post call that goes like this: function
i was wondering how/where to write a callback function after an ajax request is
I want to have one callback function after actions are done, I'm trying something
i am updating content with ajax call from server. after the update, i empty
I have a jquery Ajax call function that I use to submit form to
With a function a div-popover gets called and filled with dynamic data using Ajax,
I call a controller action using jquery ajax (see the below code), After the
I have a search page which performs an ajax call then generates results (dynamic

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.