I am creating an app using Backbone.js and cordova , i created a login form and method to get the user id and password from HTML page and call the webservice login method , the problen i was facing is i am not getting the UserName and pasword from HTML , when i Executed it in machine it was working fine, but when the app is installed in my android phone it was getting null values , i tried all the possible way but no luck
var Loginname = $('#username').val(); var Password = $('#password').val();
Loading
Osmosys OsmosysPosted Apr 18, 2014, 10:45 AM
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
but no luck, Thanks for helping me.
directory.views.SearchPage = Backbone.View.extend({
initialize: function() {
this.template = _.template(directory.utils.templateLoader.get('index1'));
},
render: function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
this.listView = new directory.views.EmployeeListView({ el: $('.textbox', this.el), model: this.model });
this.listView.render();
return this;
},
events: {
"click #btnlogin": "Login"
},
Login: function (event) {
debugger;
var define = $('.textbox').val();
// var username = $("#username").val();
// var password = $("#password").val();
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
if (username == "" ||password == "") {
//e.stopImmediatePropagation();
event.stopPropagation();
alert("Enter UserId/Password");
}
else {
alert(define);
//alert('http://?' + 'login_name=' + username + '&password=' + password);
debugger;
$.ajax({
url: 'http://?' + 'login_name=' + username + '&password=' + password,
async: false,
type: "GET",
success: function (data) {
//if (data.ContactId!=null) {
//alert(data.ResponseId);
// alert("Login Successfull.");
if (data.ResponseId == "0") {
alert("Login successful.");
window.location.href = "#Login";
// ClearDetais();
_isValidateLogin = true;
localStorage = {
setItem: function (key, value) { },
getItem: function (key) { return null; }
};
localStorage.setItem("ICName", JSON.stringify(data.ResponseId));
localStorage.setItem("ICID", data.ICID);
localStorage.setItem("IAID", data.IAID);
localStorage.setItem("ialastname", data.ialastname);
localStorage.setItem("iafirstname", data.iafirstname);
localStorage.setItem("IAPhone", data.IAPhone);
localStorage.setItem("IAEmail", data.IAEmail);
localStorage.fax("fax", data.fax);
// alert(localStorage.getItem("ICName"));
}
else {
// ClearDetais();
alert("Wrong EmailID/Password");
this.off();
}
// LoginDetails = "";
//}
}
});
}
Rahat KhannaPosted Apr 18, 2014, 2:58 AM
You have to check once again that you are not using a CDN link but referencing a local jQuery Library and try again. If this does not solve your problem, then you can use native javascript to get the values. For Ex:
var Loginname = document.getElementById('username').value;
var Password = document.getElementById('password').value;
If this also does not work, please upload your index.html source code. I will debug it and let you know.