bigjo 1 Posted September 3, 2012 Report Share Posted September 3, 2012 (edited) Hi, I have a html page (build with xml en xsl). I want to update my database when someone visits the page with the date and url page. I want it to be done when someone visits the page. I want to get track on how many times a page has been visited and when. The user don't have to click on anything, it has to be stored when the page is opening. I thought to do it to add a javascript that update the database, but it is not a good idea because javascript is client based. So I thought a could call a jsp file (where the code is written to update the database) when the html page loads.The problem is that I don't know how to call the jsp file, without loading it in the browser. I find something like this: <script language="JavaScript"> function updateStats(){ var jspcall="url.jsp" window.location.href=jspcall } </script> and then I tried with <body onload="updateStats()"> But then ofcourse the page is loaded. Someone an idea how I could do it properly? Edited September 3, 2012 by bigjo 1 Quote Link to post Share on other sites
smiles 7 Posted September 4, 2012 Report Share Posted September 4, 2012 (edited) Hi! You should get familiar with AJAX, it is so popular http://w3schools.com...ax_examples.aspAfter understand somehow about it, I recommend jQuery.ajax http://www.w3schools...jquery_ajax.asp Edited September 4, 2012 by smiles Quote Link to post Share on other sites
Raviteja.Kodati 0 Posted January 11, 2013 Report Share Posted January 11, 2013 Try this code.. HTML code:<head><script src="hidden.js" type="text/javascript"></script><.head><body onload="create()"></body> Create a java script file and write below script: var xhr;function create(){if(window.XMLHttpRequest)xhr=new XMLHttpRequest();else if(window.ActiveXObject)xhr=new ActiveXObject("Microsoft.XMLHTTP");}add this to d function for action listener.var url="yourown.jsp?num1="+num1.value+"&num2="+num2.value; xhr.open("GET",url,true); xhr.send(null); U can write ur own code in 'yourown' jsp file. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.