unerwartetes token Fehler beim Aufruf einer Funktion in einen callback

auf den Anruf wieder nach dem ajax-Aufruf in qm150_submit $.post ....
Ich will, nennen eine zweite Funktion, die aufgerufen wird 'send_email' (das hat auch einen callback namens 'success_callback'

Ich eine Fehlermeldung, hier

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

Fehler: Uncaught SyntaxError: Unexpected token )

hier ist der 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: und der code für die 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;
}
InformationsquelleAutor johowie | 2012-02-12
Schreibe einen Kommentar