未捕获的类型错误:对象 [object DOMWindow] 的属性不是函数

发布于 2025-01-05 02:49:05 字数 2100 浏览 3 评论 0原文

在 qm150_submit $.post 中的 ajax 调用之后的回调中...... 我想调用第二个名为“send_email”的函数(它还有一个名为“success_callback”的回调,

调用了 send_email 但出现此错误:

Uncaught TypeError: Property 'send_email' of object [object DOMWindow] is not a function

这是引用错误吗?我需要做一些事情来设置.this 可能是

有关?

从 colorbox iframe 调用的函数 qm150_submit() 我不确定这是否与此 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');
        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
}

以及 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;
}

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'

the send_email is called but I get this error:

Uncaught TypeError: Property 'send_email' of object [object DOMWindow] is not a function

is this a reference error? do I need to do something to set what ever .this is perhaps??

function qm150_submit() is called from with an colorbox iframe. I'm not sure if that has anything to do with it ?

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');
        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
}

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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆夏时光 2025-01-12 02:49:05

而不是

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

仅仅调用该函数。

send_email(fromName,fromEmail,toEmail,subject,message,success_callback);

Instead of

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

Just call the function.

send_email(fromName,fromEmail,toEmail,subject,message,success_callback);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文