Solved

Updating a web document using ajax

Posted on 2008-10-22
3
666 Views
Last Modified: 2013-12-18
I have a web application where users amend a document on the web. There is lots of information to be captured and this information needs to be on one screen for ease of use. We have a problem where users say their browsers crash and their information is lost. We want to implement autosave using ajax on our form. I am a novice at Ajax and from what I have read, we use the ajax code to submit the request to the server. This I have working. BUT

The listening mechanism I have for the request is an agent. So basically, when I send the request I specify the url to the agent and I include the doc id , the field name and the field value in the queryString.
The problem I am concerned about it that the agent will go and find the backend document make the change to the field and save the document. But the user is still busy editing the document and when they save the document, it sends a proper save to the server. Will this cause a save conflict on the document when the user saves the document as we have saved the document in the backend and now those same fields are sent back to the server ?

Is there another approach to implementing autosave over the web ?
Is there another listening mechanism in domino other than an agent to sort out the update to the field ?

var xmlHttp;

function createXMLHttpRequest() { 

  if (window.ActiveXObject) { 

    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 

  }

  else if (window.XMLHttpRequest) { 

    xmlHttp = new XMLHttpRequest(); 

  }

}
 
 
 
 

function AutoSave()

{

var CurrLocation = new String (window.location)

var LocationSplit = CurrLocation.split("/")

var server = LocationSplit[0] +"//" + LocationSplit[2] 

var path = document.forms[0].dbpath.value
 

var pos=0;
 

currURL = (document.location.href).toLowerCase();
 

if (trim(server) == "") {

pos = currURL.indexOf('://'); 

if (pos < 0 )

{

	var CurrLocation = new String (window.location)

	var LocationSplit = CurrLocation.split("/")

	var server = LocationSplit[0] +"//" + LocationSplit[2] 

}

//server = "http://Localhost" // PUT YOUR SERVERNAME HERE

else

{

pos += 3;

pos = currURL.indexOf('/', pos);

server = currURL.substring(0, pos)

}

}
 

if( trim(path) == "" )

{

if( pos > 0 )

{

newPos = currURL.indexOf('.nsf',pos);

if (newPos > 0)

{

path = currURL.substring(pos+1,newPos+4)

}

}

}
 

//Javascript index starts at 0, so need to decrement the column by -1

var args='&docID=' + document.forms[0].DocID.value + "&testing=" + document.forms[0].Testing.value

vurl = trim(server)+"/"+trim(path)+"/UpdateMyDocument?openagent" + args

alert(vurl)
 

  createXMLHttpRequest(); // build update string

  alert("1")

  //xmlHttp.onreadystatechange = this.handleStateChange;

  alert("2")

  xmlHttp.open("GET" ,vurl ,true);

  alert("3")

  xmlHttp.send(null);

  alert("4")

	//UpdateMyDocument
 

}
 
 
 

function trim(sStr)

{

var iI = 0;

var iJ = 0;

var iTam = 0;

var sAux = "";
 

iTam = sStr.length;

if(iTam==0) return(sStr);
 

for(iI=0; iI<iTam; iI++)

if(sStr.charAt(iI)!=' ') break;
 

if(iI >= iTam) return("");
 

for(iJ=iTam - 1; iJ>=0; iJ--)

if(sStr.charAt(iJ)!=' ') break;
 

return(sStr.substring(iI,iJ+1));

} //End of trim

Open in new window

0
Comment
Question by:devguru001
3 Comments
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 22794444
I suppose it could work, but what you should know is that a Domino server uses an intermediate document as a cache for the front-end. Such an intermediate document is created also when the user opens a new document with a form.

Just my 2 ideas therefore:
1) why not implement a simple button with only @Command([FileSave]) ?
2) Give them a GOOD browser (like Firefox 3), instead of spending lots of $$ on development and maintenance
0
 
LVL 1

Expert Comment

by:quzzie
ID: 24785870
I'm not a fan of AJAX.  it tends to add significant complexity to a problem that can usually be solved without it.

If the fundamental problem is that the users are filling in a really big form that sometimes crashes and they lose data cos the form is so big it takes too long to complete, then one solution would be to break the form down.

you often see on web sites (such as shopping carts, questionaires, surveys) the form split in to sections.  As you progress from section to section you save the document.  you could either split the notes back end document up into smaller chunks, or as SJEF suggests, just do a filesave after each section
0
 

Author Closing Comment

by:devguru001
ID: 31508662
There were other issues involved.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now