在 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 回答
- 0 關注
- 191 瀏覽
添加回答
舉報
0/150
提交
取消