【问题标题】:javascript change xml file on the serverjavascript更改服务器上的xml文件
【发布时间】:2018-02-06 17:58:35
【问题描述】:

我正在 Eclipse 中制作一个 Design Studio 自定义组件。我在contribution.xml 文件中创建了一个属性“backgroundColor”。我可以在我的 javascript 中调用这个 xml 文件并在本地对其进行调整,但是有没有办法可以再次将这些更改上传到服务器 xml 文件?因为目前我的警报返回所有新数据,但在服务器端没有任何反应。

我拥有的代码:

贡献.xml:

<property
        id="backgroundColor"
        title="BackgroundColor"
        type="Color"
        group="Display"
        visible="true"
        bindable="true"/>

component.js:

var xhttp = new XMLHttpRequest();
                xhttp.onreadystatechange = function() {
                    if (this.readyState == 4 && this.status == 200) {
                        myFunction(this);
                    }
                };
                xhttp.open("GET", "serverpath/contribution.xml", true);
                xhttp.send();

                function myFunction(xml) {

                    xml.responseXML.getElementsByTagName('property')[0].setAttribute("visible",false);
                    //this returns BackgroundColor so the call does work
                    alert(xml.responseXML.getElementsByTagName('property')[0].getAttribute("title"));

                }

【问题讨论】:

    标签: javascript jquery xml


    【解决方案1】:

    您需要进行一些服务器端编码才能做到这一点。您可以通过制作简单的 rest api 来实现。但否则,如果没有任何服务器端编码,您将无法做到这一点。您现在通过 GET 请求向服务器获取数据,这意味着您无法进行任何修改,您只需获取任何服务器响应数据。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    • 2012-04-21
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多