Android problems with reg window WP post

You must Login before you can answer or comment on any questions.

OK.

Can someone pls tell me why this wont work with Android?

var win = Ti.UI.currentWindow;
 
 
 
                    ///--------------------Top & Foooter----------------------
 
var top = Ti.UI.createImageView({
    width: '100%',
    top: 0,
    image   : 'images/footer.png',
    zIndex  : 5
});
win.add(top);
 
var footer = Ti.UI.createImageView({
    width: '100%',
    bottom: 0,
    image   : 'images/foter.png',
    zIndex  : 5
});
win.add(footer);
 
                     ///-------------------Top & Footer End---------------------
 
var bgImage = Ti.UI.createImageView({
    canScale: true,
    enableZoomControls:false,
    top     : 45,
    image   : '/images/bg.png',
    zIndex  : 0
});
win.add(bgImage);
 
 
var scrollView = Ti.UI.createScrollView({showVerticalScrollIndicator:true, showHorizontalScrollIndicator:false, contentHeight:'auto'});
 
var view = Ti.UI.createView({height:'auto', width:'auto'});
 
var txtUsername = Ti.UI.createTextField({height:'40dp', backgroundColor:'white', paddingLeft: '6dp', width:'200dp', top:'20dp', hintText:'Användarnamn' });
var txtEmailId = Ti.UI.createTextField({height:'40dp', backgroundColor:'white', paddingLeft: '6dp',width:'200dp', top:'70dp', hintText:'Email' });
var txtFirstName = Ti.UI.createTextField({height:'40dp', backgroundColor:'white', paddingLeft: '6dp',width:'200dp', top:'120dp', hintText:'Förnamn' });
var txtLastName = Ti.UI.createTextField({height:'40dp', backgroundColor:'white', paddingLeft: '6dp',width:'200dp', top:'170dp', hintText:'Efternamn' });
var txtPassword = Ti.UI.createTextField({passwordMask:true, height:'40dp', backgroundColor:'white', paddingLeft: '6dp',width:'200dp', top:'220dp', hintText:'Lösenord' });
var txtConfirmPassword = Ti.UI.createTextField({passwordMask:true, height:'40dp', backgroundColor:'white', paddingLeft: '6dp',width:'200dp', top:'270dp', hintText:'Lösenord igen' });
 
var btnSubmit = Ti.UI.createButton({
    labels:[{title:"Skicka", width:100}],
    //style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
    backgroundColor:'#037f0f',
    left: '35dp',
    top:350,
    zIndex:110,
    height:40,
    width:'auto'
    });
var btnReset = Ti.UI.createButton({
    labels:[{title:"Rensa", width:100}],
    //style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
    backgroundColor:'#7f0303',
    right: '35dp',
    font    : '24dp',
    top:350,
    zIndex:110,
    height:40,
    width:'auto'
    });
 
btnSubmit.addEventListener('click', function() {
 
try{
 
    var xhr = Ti.Network.createHTTPClient();
 
    xhr.onload = function() {
 
        Ti.API.info('Du har registrerats!');
        Titanium.UI.createAlertDialog({
 title: 'Järnvägs VIP',
 message:'Du har registrerats som VIP!\n\nNu kan du logga in med uppgifterna du uppgav på www.jarnvags.se \n\nDu kommer även att få vårt exklusiva nyhetsbrev.'
        }).show();
        //var json = JSON.parse(this.responseText)
        //Ti.API.info(this.responseText);
 
        Reset();
    };
 
    xhr.onerror = function() {
 
        Ti.API.info('Registrering misslyckades!');
        alert('Registrering misslyckades!');
 
        //var json = eval('(' + this.responseText + ')');
        //Ti.API.info(json.status);
 
        Reset();
    };
 
    //var url = "http://jarnvags.se/s-wordpress/wp-login.php?action=register";
    var url = "http://jarnvags.se/s-wordpress/wp-login.php?action=register";
    xhr.open("POST", url);
 
    var params = {
        user_login : txtUsername.value,
        user_email : txtEmailId.value,
        first_name : txtFirstName.value,
        last_name : txtLastName.value,
        pswd1 : txtPassword.value,
        pswd2 : txtConfirmPassword.value
    };
 
    xhr.send(params);
}
catch(e){
    Ti.API.info(e);
}
}); 
 
function Reset(){
    txtUsername.setValue('');
    txtEmailId.setValue('');
    txtFirstName.setValue('');
    txtLastName.setValue('');
    txtPassword.setValue('');
    txtConfirmPassword.setValue('');
};
btnReset.addEventListener('click', function(){
    Reset();
});
 
 
view.add(txtUsername);
view.add(txtEmailId);
view.add(txtFirstName);
view.add(txtLastName);
view.add(txtPassword);
view.add(txtConfirmPassword);
 
view .add(btnSubmit);
view .add(btnReset);
 
scrollView.add(view);
win.add(scrollView);
I get the "process com.whatever has Stopped unexpectlady" Error

It works fine with iOS.

1 Answer

Accepted Answer

Use DDMS, found in the android/tools directory on your system (which we don't know the platform because you didn't ask your question properly) to see the error thrown on the emulator or device (again, incomplete question)...

You know, I'll just say:

Missing from your question are a number of important pieces of information. I suggest you take a look at the Using Questions and Answers article, specifically the Q&A Question Checklist. The missing information is critical to reproducing problems in a test environment and often indicates other factors that cause the undesirable outcome you are experiencing.

— answered 8 months ago by Stephen Feather
answer permalink
1 Comment
  • Ok fair enough...

    My guess that someone just could have seen what was wrong with the code.

    As i figured out it didnt work because of the buttons in the view. It worked when i put the buttons outside the view in the same win.

    Strange? Yes. but now it works.

    I am sorry for not doing the Q right and i will be better on it.

    Peace!

    — commented 8 months ago by Richard Harrysson

Your Answer

Think you can help? Login to answer this question!