|
|
Hi All,
If a session has timed out, would the following code still get to a readyState of 4?
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
Thank you,
Mel
|
|
|
|
|
Don't get me wrong I understand that the readyState can be 0-4, with the following meanings:
0 Uninitialized
1 Server connection established
2 Request recieved
3 Interactive - processing request
4 Request Complete
But what I want to know is, if the session has timed out can the readyState still reach 4?
Thanks,
Mel
|
|
|
|
|
On thinking about it, I would say maybe. Mainly due to a page does not refresh and so the last loaded session is still in effect on the users browser. So an ajax call should still return...unless the ajax is also tied to the session state. If the ajax is free of the session state then there is no issue until the page is refreshed (or post, navigation, etc...) but this should be tested first to be sure as I am just guessing and I am basing my idea on how php sessions work.
Chris J
www.redash.org
|
|
|
|
|
Hi cjoki,
Thank you for your reply. I have tested it and the result is that even though the session has expired the Ajax code still reaches a state of 4, so your theory may be right as the code isn't linked to the session.
I was thinking the Ajax code should fail though because it's carrying out calls to the server and without a session, so shouldn't the calls be impossilble?
Do you know of a way I can connect the Ajax code to the session?
Thank you,
Mel
|
|
|
|
|
What I ended up doing was to test in the aspx file (the file called by Ajax open()) if the sesison still existed. If the session existed then allow the code to run if not then send the user to the login page.
I just feel like the Ajax code should be able to detect itself if the session has expired and therefore the state shouldn't reach 4.
This is new to me though so any feedback would be really appreciated.
Thanks,
Mel
|
|
|
|
|
Would this behaviour be any different than if you clicked a link to a page that also did not reference the session?
I think it was left up to the programmer to do the test or not. Ajax is only meant to load a html fragment (or data processing via text, XML, json, etc...) not an entire page. So if someone logs into a web-based dashboard lets say of live stock quotes, do you really want to force that person to relog after every 30 minutes? On the other hand you may design a online bank account system for personal and business customers to handle checking and bill payment, a session timeout of 30 min may be way to long and so an automatic session expiration check make sense. In the end Ajax is just another tool in the toolbox and it is up to us programmers to determine the pros and cons of any design choice...again just my oppinion.
Chris J
www.redash.org
|
|
|
|
|
Dear Experts!
I have any object with classid embedded in html.
That object exposes a method with take C# reference (ref) parameter integer.
I want to call that method using javascript.
var refInt = 0;
document.getElementById("myObject").GetReferenceInt(ref refInt);
alert(refInt);
Please tell me how I can get that. I have seen ref is a keyword in JavaScript.
Can't find any solution for this. Please guide how to use object if this is not appropriate.
Thank you.
|
|
|
|
|
AKAIK ref is not a keyword in JavaScript. If GetReferenceInt is a C# method it cannot be called in this manner. You would need to use something like PageMethods or other AJAX methods to obtain the value and even then you cannot use a ref parameter.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you.
Please guide me about PageMethods or AJAX method you are referring. I am stuck on this particular situation
|
|
|
|
|
|
Hi All,
I've been trying to put to work the session timeout code from Eric Pascarello site:
http://www.pascarello.com/AjaxSessionTimer.aspx[^]
The problem I'm having it that
if(reqXML.responseText.indexOf("Session Updated - Server Time:") == 0) is always true, even when the session has expired. I added
<%@ OutputCache Location="None" VaryByParam="None" %> to the AjaxSessionUpdate.aspx page but still the if statement is true. Each time the "Confirm" button is pressed a new time is returned.
Does anyone know why this if statement never returns false when the session has expired?
Thank you,
Mel
|
|
|
|
|
This is the code of AjaxSessionUpdate.aspx.vb:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.ContentType = "text/html"
Response.Write("Session Updated - Server Time:" & Date.Now.ToString)
End Sub
Calling this page will always yield a string starting with "Session Updated - Server Time:" and thus indexOf will always yield 0. This means the string was found at position 0 the start if the string.
What did your expect?
|
|
|
|
|
Thank you for your quick reply.
Good question, I expected that the req.responseText (strDoc) wouldn't include the "Session Updated - Server Time:" string. I thought AjaxSessionUpdate.aspx would only be called if the session was open, because if the session was closed wouldn't
if(this.req)
in net.js be false and therefore
this.req.open(method,url,true)
(where the url is AjaxSessionUpdate.aspx) wouldn't be called?
If AjaxSessionUpdate.aspx is always called then the session would never be shown as expired in Eric's code and the message "Warning your session has already timed out!" wouldn't be shown, which defeats the object of the code.
Please let me know if there is a way for me to treak the code in order to get it working as expected.
Thank you again,
Mel
|
|
|
|
|
Does anyone have any thoughts on this?
Thank you,
Mel
|
|
|
|
|
function ProcessAction() {
PageMethods.CheckSessionExpiration(OnCheckSessionExpirationComplete, OnCallError);
if (IsLogin == true) {
alert("Inside the Function");
var txtNote = $("[id$=txtNote]").val();
var txtIdentNo = $("[id$=txtIdentNo]").val();
var sIdentNo = "";
DisableControls();
CleanIdentNoList();
if (ValidFields()) {
gAction = $("[id$=cmbAction]").val();
gNote = txtNote;
sIdentNo = jQuery.trim(txtIdentNo);
gMSISDNList = sIdentNo.split("\n");
gMSISDNIndex = -1;
ProcessNextItem();
}
else {
EnableControls();
}
}
else {
window.location = "Login.aspx";
}
}
and i have a Callback function defined like this
function OnCheckSessionExpirationComplete(result,methodName) {
if (result == false) {
IsLogin = false;
}
else {
IsLogin = true;
}
}
Now the "IsLogin" variable is a Global variable defined like this
var IsLogin = true;
What i want to do is to redirect the user if the Session is null, as you can see i have added the line
System.Web.HttpContext.Current.Session["CurrentLoginUser"] = null;
For testing Purpose , but my problem is is that, even if its null, the
alert("Inside the Function");
is fired, what i am i doing wrong.
THanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
PageMethods are asynchronous, meaning that PageMethods.CheckSessionExpiration will be executed and it will proceed to the next statement if (IsLogin == true) . Move this logic to the OnCheckSessionExpirationComplete method
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks that saved my life
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I have been working on a table which user can select some cells. After selection data
will be sent to server to process.
i want to select district cells, but htmls own select mechanism works line-base.
So, i want to enable/disable multiselecting a table's cells. Is it possible?
i run into a similar feature in html5 but my work is on earlier version.
when table cells are empty, multiselect does not happen. In addition, it tries to drag and drop
block elements.
Thank you in advance
asbasir
|
|
|
|
|
Hi,
I have another javascript on a poppup window in asp.net to return the value back to the parent .
but it gives me an error: opener.document is null or not an object.
opener.document.getElementById("TextBox1").value = "hello";
I even ammended the main parent javascript so as to open this popup as a return value back to a variable.
any help will be highly appreciated.
Thanks
|
|
|
|
|
The error message seems quite clear: opener.document is not an object, that is it has not been initialised to point at a valid object.
I must get a clever new signature for 2011.
|
|
|
|
|
Not sure what you're doing...I've barely scratched the surface of javascript...but you say you're using a MasterPage.
That being the case, "TextBox1" won't be the ID of the control. It will be more like "ctl00_MainContentPlaceHolder_TextBox1" or similar.
View the source of your webpage when it's running to find the runtime name and see if that helps.
|
|
|
|
|
Hello,
I have a simple menu bar base on a ul li list with embedded hyperlinks.
<ul>
<li id="menuHome"><a href="index.html" onMouseOver="setMenu('menuHome')" >Home</a></li>
<li id="menuResults"><a href="results.htm">Results</a></li>
<li id="menuEvents"><a href="events.htm">Events</a></li>
</ul>
I have set the CSS properties such as
#menuHome {
background-color: #CCC;
color: #000;
}
#navleft ul {
list-style: none;
padding: 0;
margin: 0 0 5px 0 ;
text-align: left;
}
#navleft li {
margin: 5px 0;
line-height: 23px;
}
#navleft li a {
text-decoration: none;
padding-left: 9px;
display: block;
width: 140px;
}
My Java script is quite basic
function setMenu( id )
{
var e = document.getElementById(id);
e.style.backgroundColor = 0x666666;
e.style.color = 0xFFFFFF;
}
My goal is to basically have a vertical menu bar that can be used for multiple webpages, so that after the user clicks on it, it will change the background color and text to a different color, so that it is apparent which page the user is on.
(I realize that I'm using the mouse hover for testing, it stops the page from reloading every time I test it).
The problem that I am having, if my understanding is corrent is that the tag that I pass in the jave call is bond to the "li" element of the menu list, the background color changes quite fine, but, I can not seem to be able to access the color property of the "a href" tag to change the text from black to white.
using the e.style example above how would to "Cast it" to the a reference?
Thank you in advance.
|
|
|
|
|
Hi All,
I am having a script file which begins with the following statement:
var ABC = ABC || {};
This is the very first line of the Java Script file, while the remaining is understandable.
Can anyone please tell me what does this line means.
I am unable to understand the meaning of it
Thanks
|
|
|
|
|
Let me reply my Question:
The following line creates namespace in Java script:
var ABC = ABC || {};
It says if there is a class called ABC create a namespace of it, otherwise create a blank namespace.
Hope this may help others for understanding.
|
|
|
|