Javascript 未捕获的TypeError:this.$.AjaxPost.go不是函数核心ajax

Javascript 未捕获的TypeError:this.$.AjaxPost.go不是函数核心ajax,javascript,ajax,polymer,Javascript,Ajax,Polymer,我已经写了一个HTML页面为我们的网站密码重置,我们希望它是后调用服务器。我们使用的是聚合物,代码: <dom-module id="user-password-reset"> <template> <div class="popup"> <h5 class="popup-heading">Forgot Password</h5> <div class="popup-body">

我已经写了一个HTML页面为我们的网站密码重置,我们希望它是后调用服务器。我们使用的是聚合物,代码:

<dom-module id="user-password-reset">

<template>
    <div class="popup">

        <h5 class="popup-heading">Forgot Password</h5>

        <div class="popup-body">
            <div class="form-group">
                <label for="FormInput-UserEmail">Provide your Email Address</label>
                <input type="email" class="form-control" id="FormInput-UserEmail" placeholder="name@example.com" value="{{ email::input }}">
            </div>
            <br/>
            <div class="text-center">
                <button type="button" class="btn" on-click="onSubmit">Reset Password</button>
            </div>
        </div>

    </div>

    <core-ajax
        id="AjaxPost"
        auto="false"
        url="/api/user/email"
        method="POST"
        content-type="application/json"
        handle-as="json"
        on-core-response= _handleAjaxPostResponse
        on-core-error= _handleAjaxPostError
        ></core-ajax>

</template>


<script>
    Polymer({

        is: 'user-password-reset',

        behaviors: [
            Polymer.IronOverlayBehavior
        ],

        properties: {
            email: { type: String },
        },

        onSubmit: function( event ) {
            this.$.AjaxPost.params = JSON.stringify( { email: this.email } );
            console.log( this.$.AjaxPost );
            this.$.AjaxPost.go();
        },

        _handleAjaxPostResponse: function( event ) {
            /* Do Something */
        },

        _handleAjaxPostError: function( event ) {
            /* Do Something */      
        },
    });

</script>

</dom-module>

我现在该怎么办?

我已经有过这样的问题了,有时还会回来

尝试使用noConflict,因为jquery可能与您正在运行的内容冲突

本页帮助我:
对不起,我忘了提到polymer的版本。我们使用聚合物1.0,感谢本·托马斯指出这一点。解决方案非常简单,不需要将其转换为Json,也不需要使用iron ajax代替核心ajax

守则:

<iron-ajax
        id="AjaxPost"
        url="/api/user/email"
        method="POST"
        content-type="application/json"
        handle-as="json"
        on-response="_handleAjaxPostResponse"
        on-error="_handleAjaxPostError"
        ></iron-ajax>

var ajaxPost = this.$.AjaxPost;
            ajaxPost.params = { email: this.email };
            ajaxPost.generateRequest();

请注意,如果您使用Post调用,那么最好在params中发送数据,而不是在body中的某个地方读取数据。发送时,不要将其字符串化。

这是一条评论,而不是答案。这里没有使用jQuery。您能澄清您使用的聚合物版本吗?您的用户密码重置元素是使用1.0语法声明的,而您使用的是core ajax,它是1.0之前的一个旧聚合元素。核心-*元素现在不再使用,已被铁-*元素取代。查看聚合物元素的当前版本。您将发现一个名为iron ajax的应用程序,您可能应该改用它。
Uncaught TypeError: this.$.AjaxPost.go is not a function
<iron-ajax
        id="AjaxPost"
        url="/api/user/email"
        method="POST"
        content-type="application/json"
        handle-as="json"
        on-response="_handleAjaxPostResponse"
        on-error="_handleAjaxPostError"
        ></iron-ajax>

var ajaxPost = this.$.AjaxPost;
            ajaxPost.params = { email: this.email };
            ajaxPost.generateRequest();