Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript iron ajax未将输入数据发布到php_Javascript_Php_Ajax_Polymer_Polymer 1.0 - Fatal编程技术网

Javascript iron ajax未将输入数据发布到php

Javascript iron ajax未将输入数据发布到php,javascript,php,ajax,polymer,polymer-1.0,Javascript,Php,Ajax,Polymer,Polymer 1.0,聚合物元素脚本的一部分: <content> <iron-ajax id="plWhois" method="POST" body='{"helper":"plugin", "func":"_pluginsInitAjax", "params":{"domain": "domain", "request_type": "taken"}}' handle-as="json" on-response="handleResponse" debounce-dur

聚合物元素脚本的一部分:

<content>
            <iron-ajax id="plWhois" method="POST" body='{"helper":"plugin", "func":"_pluginsInitAjax", "params":{"domain": "domain", "request_type": "taken"}}' handle-as="json" on-response="handleResponse" debounce-duration="300"></iron-ajax>
            <paper-card heading="Begin the search for your perfect domain name..." image="themes/custom_components/apps/pl-whois/img/who-is.jpg" center>
                <div class="card-content">
                    <paper-input id="plWhoisSearchBtn" type="search" placeholder="e.g. mydomain.com">
                        <iron-icon prefix icon="search"></<iron-icon>
                    </paper-input>
                </div>
                <div class="card-actions s-t">
                    <paper-button on-click="domainAvailability">Search</paper-button>
                    <paper-button>Transfer</paper-button>
                </div>
                <div class="card-actions p-l">
                    <paper-button>buy a domain</paper-button>
                    <paper-button>order hosting</paper-button>
                    <paper-button>make payment</paper-button>
                    <paper-button>support</paper-button>
                </div>
            </paper-card>
  </content>

<script>
        // element registration
        Polymer({
            is: "pl-whois",
            properties: {
                url: {
                    type: String,
                                notify: true,
                    value: ''
                },
                body: {
                    type: Object,
                                notify: true,
                    value: ''
                }
        },
            domainAvailability: function () {
                var domain = this.$.plWhoisSearchBtn.value;

                this.$.plWhois.url = "ajax.php";
                /*this.$.plWhois.body = {"helper":"plugin", "func":"_pluginsInitAjax", "params":{"domain": domain, "request_type": "taken"}};
                */
                this.$.plWhois.generateRequest();
            },
            handleResponse: function(e) {
                console.log(e.detail.response);
            }
        });
    </script>


看起来您的
调用缺少
url
属性。

我仍然遇到同样的问题,看起来像是一个bug什么的,(动态导入的脚本在iron ajax请求期间不会发送post数据)

因此,作为一种解决方法,从元素的属性中获取url和主体值,然后将它们绑定到iron ajax似乎是可行的:

Iron ajax:

{{url}”body=”{{params}”在response=“handleResponse”debounce duration=“300”上处理为=“json”

此脚本将属性添加到my元素中,并触发iron请求:

现在这就是我导入的元素的外观(部分):

//导入

用添加URL的脚本标记编辑了我的问题有问题的网站是(),在输入和点击搜索中输入一个单词,它不会发送输入数据这里是元素的完整脚本(),看起来Ajax请求完成了,因为HandlerResponse方法打印出一个对象:{err:“helper类必须是string类型,(NULL)given!”}。我建议您使用类似Postman的工具调试ajax端点,以查明问题所在。
var domain = this.$.plWhoisSearchBtn.value;

this.url = 'ajax.php';
this.params = '{"helper":"plugin", "params":{"0":"whoapi_dot_com", "1":"_test", "2":{"0": "'+domain+'", "1": "taken"}}}';     
this.$.plWhois.generateRequest();
//imports
<dom-module id="pl-whois" class="wide-layout-mq">
    <template>
  <style></style>
      <iron-ajax id="plWhois" method="POST" url="{{url}}" body='{{params}}' handle-as="json" on-response="handleResponse" debounce-duration="300"></iron-ajax>

  <content>
            <paper-card heading="Begin the search for your perfect domain name..." image="themes/custom_components/apps/pl-whois/img/who-is.jpg" center>
                <div class="card-content">
                    <paper-input id="plWhoisSearchBtn" type="search" placeholder="e.g. mydomain.com" on-keyup="updateParams">
                        <iron-icon prefix icon="search"></<iron-icon>
                    </paper-input>
                </div>
                <div class="card-actions s-t">
                    <paper-button on-click="domainAvailability">Search</paper-button>
                    <paper-button>Transfer</paper-button>
                </div>
                <div class="card-actions p-l">
                    <paper-button>buy a domain</paper-button>
                    <paper-button>order hosting</paper-button>
                    <paper-button>make payment</paper-button>
                    <paper-button>support</paper-button>
                </div>
            </paper-card>
  </content>
</template>

<script>
    // element registration
    Polymer({
        is: "pl-whois",
        properties: {
            url: {
                type: String,
                notify: true,
      reflectToAttribute: true,
                value: ''
            }
    },
  updateParams: function (e) {
    var domain = this.$.plWhoisSearchBtn.value;

    this.url = 'ajax.php';
            this.params = '{"helper":"plugin", "params":{"0":"whoapi_dot_com", "1":"_test", "2":{"0": "'+domain+'", "1": "taken"}}}';

    if(e.keyCode === 13){
      this.$.plWhois.generateRequest();
    }
        },
        domainAvailability: function () {
    var domain = this.$.plWhoisSearchBtn.value;

    this.url = 'ajax.php';
            this.params = '{"helper":"plugin", "params":{"0":"whoapi_dot_com", "1":"_test", "2":{"0": "'+domain+'", "1": "taken"}}}'; 

            this.$.plWhois.generateRequest();
        },
        handleResponse: function(e) {
            console.log(e.detail.response);
        }
    });
</script>