Posted on 02/09/2015 13:36:04
Hi Morten,
Well I got some progress a bit, atlest some more clues.
As soon as I change it to Post, instead of Get I am getting a null pointer excption (in JSon template) not sure what is that all about.
If I change it back to Get, all is OK again.
I am not using anything extra ordinary that would give null pointer, in JSon template trying to keep it as save as possible to avoid those.
here is my implementation of the call and post:
function jsonLoggin(pageid) {
var username = $("#inputEmail").val();
var password = $("#inputPassword").val();
var DWExtranetUsernameRemember = $("input[name='DWExtranetUsernameRemember']").val();
var DWExtranetPasswordRemember = $("input[name='DWExtranetPasswordRemember']").val();
var Autologin = $("input[name='Autologin']").val(); //this DOES work!
var data = "&username=" + username;
data += "&password=" + password;
data += "&DWExtranetUsernameRemember=" + DWExtranetUsernameRemember;
data += "&DWExtranetPasswordRemember=" + DWExtranetPasswordRemember;
data += "&Autologin=" + Autologin;
ajaxGetRequest(data, pageid, ajaxLoginCaptured);
//ajaxPostRequest(data, pageid, ajaxLoginCaptured);
}
function ajaxLoginCaptured() {
var xmlhttp = arguments[0].target;
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
try {
var response = JSON.parse(xmlhttp.responseText);
if (response.userstatus == "OK" && response.grantAccess == "True") {
//reload GUI
location.reload();
} else {
alert("Something is wrong - here is response:" + xmlhttp.responseText);
}
} catch (e) {
alert("Login ajax exception:" + e.toString());
}
}
}
// general POST method
function ajaxPostRequest(data, pageid, callbackHandler) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = callbackHandler;
var url = "Default.aspx?ID=" + pageid+data;
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(data);
}
// general GET method
function ajaxGetRequest(data, pageid, callbackHandler) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = callbackHandler;
var url = "Default.aspx?ID=" + pageid + data;
//alert("step2) "+url);
xmlhttp.open("GET", url, true);
xmlhttp.send(data);
}
/Dmitrij