Uncaught TypeError:object [object DOMWindow]的属性不是一个函数 [英] Uncaught TypeError: Property of object [object DOMWindow] is not a function

查看:474
本文介绍了Uncaught TypeError:object [object DOMWindow]的属性不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ajax调用回调后在qm150_submit $ .post ....
我想调用第二个函数调用'send_email'(它也有一个回调称为'success_callback'

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'

send_email被调用,但我收到此错误:

the send_email is called but I get this error:

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

这是一个引用错误?做一些事情来设置 .this 可能是

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

function qm150_submit

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

这里是代码:

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()的代码

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


推荐答案



Instead of

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

只需调用此函数。

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

这篇关于Uncaught TypeError:object [object DOMWindow]的属性不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆