为了账号安全,请及时绑定邮箱和手机立即绑定

Iron-ajax 与 Polymer-starter-kit 行为不端或其他东西串联

Iron-ajax 与 Polymer-starter-kit 行为不端或其他东西串联

Go
喵喵时光机 2022-01-10 14:28:47
在 Firefox 开发人员工具中,我得到以下日志输出: GET XHR http://localhost:8080/localhost:8080/journal_tag即使我想去:http://localhost:8080/journal_tag我尝试将 xhr 响应应该来自的服务器位置数据绑定到变量“this.the_server_url”。但我很难过,因为当我做任何一个console.log(document.location.protocol+document.location.host+"/journal_tag")console.log(this.the_server_url)我明白了"http:localhost:8080/journal_tag"这是服务器端代码应该响应 xhr 请求的地方。因此,Firefox 开发人员工具日志告诉我,iron-ajax 或 iron-ajax 与 polymer-starter-kit 中的 page.js 结合使用是不正常的,即使它在 the_server_url 变量中具有正确的 xhr 目标。如果有人对此有任何想法,我将不胜感激。这是我的 js 代码:<dom-module id="journal-tag">  <template>    <paper-input value={{the_new_tag}}>        Enter the new tag    </paper-input>    <paper-button raised on-tap="tap_new_tag">        Submit tag    </paper-button>    <iron-ajax        auto        url={{the_server_url}}        params={{ajax_new_tag}}        handle-as="json"        on-response="new_tag_response"        last-response={{the_xhr_response}}        debounce-duration="300">    </iron-ajax>  </template>  <script>  (function() {    'use strict';    Polymer({      is: 'journal-tag',        properties:{            the_new_tag:{                type:String,                notify:true            },            the_server_url:{                type:String,                notify:true            },            ajax_new_tag:{                type:String,                notify:true            },            the_xhr_response:{                type:String,                notify:true            }        },        ready : function(){            this.the_server_url=document.location.protocol+document.location.host+"/journal_tag";        },
查看完整描述

2 回答

?
开心每一天1111

TA贡献1836条经验 获得超13个赞

有几件事。您缺少http:localhost:8080/journal_tagIt should be 中的斜线http://localhost:8080/journal_tag。此外,您可以使用您所在浏览器的开发人员工具来查看您发送的所有 XHR 请求。检查那里以查看正在发送的请求标头是什么。


查看完整回答
反对 回复 2022-01-10
?
慕桂英546537

TA贡献1848条经验 获得超10个赞

好像在做


document.location.protocol+

"//"+

document.location.host+

"/journal_tag"

修复一切。


查看完整回答
反对 回复 2022-01-10
  • 2 回答
  • 0 关注
  • 231 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号