0
        var button = Ti.UI.createButton({
            left: 180,
            top: 180,
            width: 100,
            hight: 30,
            title: 'Go'
        });
        self.add(button);

        button.addEventListener('click', function() {

        var xhr = Ti.Network.createHTTPClient();
        var authstr = 'Basic ' +Titanium.Utils.base64encode('S0009231839'+':'+ 'm8390967743!'); 
        xhr.open("GET","http://erp.esworkplace.sap.com/sap/bc/srt/wsdl/bndg_DF52FF9E9AF025F18F0400145E5ADE89/wsdl11/allinone/ws_policy/document?sap-client=800");
        xhr.setRequestHeader('Authorization', authstr);   
        xhr.setRequestHeader('Content-Type','text/xml');
        xhr.setRequestHeader('Accept-Language','en');

        alert('show');

        xhr.onload = function(e)

    {       try
        {

            //get the xml data and let it roll!
            var doc = this.responseXML.documentElement;
            // var items = doc.getElementsByTagName("atom:entry");
            var items = doc.getElementsByTagName("wsdl:portType");

            for(var c=0; c<items.length;c++){
            var item = items.item(c);
            alert(items.length);
            var attributeEmployeeLeave = items.item(c).attributes.getNamedItem("name").nodeValue;
            Ti.API.info(items.item(c).attributes.getNamedItem("name").nodeValue);       
            }
        }

            catch(E)
        {
            alert('error on xhr');
        }

按钮的响应addEventListener 不起作用

我不知道为什么!

任何人都可以给我建议!

4

1 回答 1

2

简单按钮示例

    var button = Titanium.UI.createButton({ title: 'Hello' });
    button.addEventListener('click',function(e) {
    Titanium.API.info("You clicked the button"); });

请将您的更改button.addEventListener('click', function() {button.addEventListener('click', function(e) {.

于 2012-07-04T19:10:55.187 回答