473,378 Members | 1,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to remove content displayed on browser during ajax call?

151 100+
Hi,

I am fetching mysql database by jsp via ajax.I am calling jsp from ajax function for database access and display the content in popup window. It is working fine. But when i mouse over the text i am getting content gets printed on web page too.


ajax.js

Expand|Select|Wrap|Line Numbers
  1. /* 
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6.  
  7. function loadContent(str)
  8. {
  9.  
  10.  xmlhttp=GetXmlHttpObject();
  11.  
  12.   if (xmlhttp==null)
  13.   {
  14.    alert ("Your browser does not support Ajax HTTP");
  15.    return;
  16.   }
  17.  
  18.     var url="loadJSP.jsp";
  19.     url=url+"?q="+str;
  20.  
  21.     xmlhttp.onreadystatechange=getOutput;
  22.     xmlhttp.open("GET",url,true);
  23.     xmlhttp.send(null);
  24. }
  25.  
  26. function getOutput()
  27. {
  28.   if (xmlhttp.readyState==4)
  29.   {
  30.         document.getElementById("prtCnt").innerHTML=xmlhttp.responseText;
  31.         popup(document.getElementById("prtCnt").innerHTML,'yellow');
  32.   }
  33. }
  34.  
  35. function GetXmlHttpObject()
  36. {
  37.     if (window.XMLHttpRequest)
  38.     {
  39.        return new XMLHttpRequest();
  40.     }
  41.     if (window.ActiveXObject)
  42.     {
  43.       return new ActiveXObject("Microsoft.XMLHTTP");
  44.     }
  45.  return null;
  46. }
  47.  
  48. /////////////////////////////////////////////////////////////////////////
  49.  
  50. //Pop up information box II (Mike McGrath (mike_mcgrath@lineone.net,  http://website.lineone.net/~mike_mcgrath))
  51. //Permission granted to Dynamicdrive.com to include script in archive
  52. //For this and 100's more DHTML scripts, visit http://dynamicdrive.com
  53.  
  54. Xoffset=-60;    // modify these values to ...
  55. Yoffset= 20;    // change the popup position.
  56.  
  57. var old,skn,iex=(document.all),yyy=-1000;
  58.  
  59. var ns4=document.layers
  60. var ns6=document.getElementById&&!document.all
  61. var ie4=document.all
  62.  
  63. if (ns4)
  64. skn=document.dek
  65. else if (ns6)
  66. skn=document.getElementById("dek").style
  67. else if (ie4)
  68. skn=document.all.dek.style
  69. if(ns4)document.captureEvents(Event.MOUSEMOVE);
  70. else{
  71. skn.visibility="visible"
  72. skn.display="none"
  73. }
  74. document.onmousemove=get_mouse;
  75.  
  76. function popup(msg,bak){
  77. var content="<TABLE  WIDTH=150 BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
  78. "BGCOLOR="+bak+"><TD ALIGN=center><FONT COLOR=black SIZE=2>"+msg+"</FONT></TD></TABLE>";
  79. yyy=Yoffset;
  80.  if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
  81.  if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
  82.  if(ie4){document.all("dek").innerHTML=content;skn.display=''}
  83. }
  84.  
  85. function get_mouse(e){
  86. var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
  87. skn.left=x+Xoffset;
  88. var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
  89. skn.top=y+yyy;
  90. }
  91.  
  92. function kill(){
  93. yyy=-1000;
  94. if(ns4){skn.visibility="hidden";}
  95. else if (ns6||ie4)
  96. skn.display="none"
  97. }
  98.  


Index.jsp

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <STYLE TYPE="text/css">
  4. #dek {POSITION:absolute;VISIBILITY:hidden;Z-INDEX:200;}
  5. </STYLE>
  6. <DIV ID="dek"></DIV>
  7. <script src="ajaxjs.js"></script>
  8. </head>
  9. <body>
  10.  
  11. <%
  12. for (int i =0; i < 10; i++)
  13. {
  14. %>
  15.   <script type="text/javascript" > var s = "WFS1"; </script>
  16.   <a href="#" ONMOUSEOVER="popup(s,'yellow')" ONMOUSEOUT="kill()">Hover Me!</a>
  17.   <br>
  18.   <a href="#" ONMOUSEOVER="popup('Link description here','yellow')" ONMOUSEOUT="kill()">Hover Me!</a>
  19.   <br>
  20.   <a href= "#" ONMOUSEOVER= "javascript:loadContent(s)" ONMOUSEOUT="kill()">Load Ajax content</a>
  21.   <div id="prtCnt"></div>
  22. <%
  23. }
  24. %>
  25. </body>
  26. </html>
  27.  
load.jsp

Expand|Select|Wrap|Line Numbers
  1. <%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
  2. <%@ page language="java" import="java.sql.*"%>
  3. <%@ page import="java.util.*" %>
  4. <%
  5.  String q =request.getParameter("q");
  6.  Class.forName("com.mysql.jdbc.Driver");
  7.             String connectionUrl = "jdbc:mysql://192.168.7.4/variant_db?" +"user=manish&password=";
  8.             Connection con = DriverManager.getConnection(connectionUrl);
  9.             Statement stmt = con.createStatement ();
  10.             String query = "select * from gene where entrez_symbol = '"+ q + "';"; 
  11.             ResultSet rs = stmt.executeQuery(query);
  12.             int numCols = rs.getMetaData().getColumnCount();
  13.             while(rs.next())
  14.             {
  15.                 for (int i =1; i < numCols; i++)
  16.                     out.println(rs.getString(i)); 
  17.             }
  18.             rs.close();
  19.             stmt.close();
  20.             con.close();
  21. %>
  22.  

Attached is screen shot of output. Text printed in orange is unwanted one(marked black). How to remove that content?

Regards
Attached Images
File Type: jpg Screenshot.jpg (42.7 KB, 109 views)
Dec 30 '11 #1
0 1350

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Grzegorz Smith | last post by:
Hi everyone. Does anyone know is it possible to check if ajax call was redirect? i mean I connect by Ajax to one URL but I'm redirected to other url. Is there a way to check that my request was...
1
by: Chaprasi | last post by:
Hi, I was wondering how I can achieve to display a 'Please wait loading...' message only if the ajax call is taking more than a second. The message should only appear if the Ajax call is...
4
by: Reid LI | last post by:
I just know I can do something in HTTP header like <meta http-equiv="refresh" content="5"> but can ASP.NET push, for example, new database content to browser automatically without using browser...
2
by: Zeba | last post by:
Hi guys! I'm new to JS / Ajax; I've been trying to do an Ajax call to my Webservice ( I'm using C# for code-behind). I'm not using any of the libraries available. I am sending my CustID to the...
3
by: radix | last post by:
Hello, I have a aspx page with ajax scriptmanger update panel etc. I also have public string variables on the aspx page. Whenever postback happens from Ajax update panel, at server side all...
1
by: Cartoper | last post by:
How does one go about formatting the date/time string correctly to set the If-Modified-Since to the current date/time in an AJAX call? I know I need something like this: ...
3
by: KDawg44 | last post by:
Hi, I would like a verification image for new sign ups on a website. Is there a way to call the PHP script through an AJAX call and have the image passed back and then display? Is there a way...
1
by: andwan0 | last post by:
I have a legacy classic ASP website with lots of classic AJAX (many ASP files specially made for processing AJAX requests). We are slowly migrating the website to ASP.NET 2.0 and developing under...
9
Claus Mygind
by: Claus Mygind | last post by:
I am having trouble escaping the & in a JSON.stringfy() ajax call. I don't even know if I am stating the problem correctly here. In my app I have linked json2.js from http://www.JSON.org/json2.js...
5
by: samarinder | last post by:
I am displaying the results by iterating the list in div tag say "results" in my case.For refining of search i am using ajax call. But when i am getting response back from this below snippet ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.