2017-08-29 37 views
0

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

的代码,我有:

Contribution.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")); 

       } 

回答

1

你需要做一些服务器端代码来做到这一点。你可以通过简单的休息api来实现。但是,否则没有任何服务器端编码,你不能这样做。您现在正在通过GET请求获取数据,这意味着您无法进行任何修改,只需获取任何服务器响应数据。

+0

你有没有任何一个API覆盖xml文档的例子?对不起,我是新手,只有用过和api插入SQL到以前的数据库。 – mrdeadsven

+0

这取决于你在服务器端工作的语言。它可能是PHP或JavaEE或任何其他服务器端语言。 –

+0

我可以自己决定这一点,我没有在服务器上的API,所以在PHP中的一个例子会很好,因为我的SQL一个是在PHP – mrdeadsven