473,387 Members | 1,766 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,387 software developers and data experts.

xmlHttp.responseText contains whole page

Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a solution :S.

This is the basic idea: I'm trying to implement Ajax in a Portal page created in weblogic 9.2. I've created a portlet with the name Ajax.jsp and an additional page called test.jsp. Ajax.jsp is the main portlet page. And uses the xmlHttp.open on test.jsp to get some data from the database which should then be shown in ajax.jsp. I've now temporary put the responsetext in a textfield because when I run this the responsetext contains the whole Portal page (without the data from test.jsp). when I run ajax.jsp as a standalone page it works and get's the right output. Could somebody give me some help?

the code for ajax.jsp=

Expand|Select|Wrap|Line Numbers
  1. <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
  2. <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
  3. <html>
  4. <body>
  5. <script type="text/javascript">
  6. function ajaxFunction(){
  7.   var xmlHttp;
  8.  
  9.   var url="test.jsp?input=";
  10.  
  11.   //var url="ajax.do?input= ";
  12.   //var url="ajax.do";
  13.   try{
  14.     // Firefox, Opera 8.0+, Safari
  15.     xmlHttp=new XMLHttpRequest();
  16.     }
  17.   catch (e){
  18.     // Internet Explorer
  19.     try{
  20.       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  21.       }
  22.     catch (e){
  23.       try{
  24.         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  25.         }
  26.       catch (e){
  27.         alert("Your browser does not support AJAX!");
  28.         return false;
  29.         }
  30.       }
  31.     }
  32.     xmlHttp.onreadystatechange=function(){
  33.       if(xmlHttp.readyState==4){
  34.  
  35.         //document.getElementById("txtHint").innerHtml= xmlHttp.responseText;
  36.         document.myForm.text.value= xmlHttp.responseText;
  37.  
  38.         }
  39.       }
  40.       //document.myForm.text.value= url+document.myForm.channelID.value;
  41.     xmlHttp.open("GET",url+document.myForm.channelID.value,true);
  42.  
  43.     //xmlHttp.open("GET",url,true);
  44.     xmlHttp.send(null);
  45.   }
  46. </script>
  47.  
  48.  
  49. <netui-data:declarePageInput name="channel" type="java.lang.Long" required="true" />
  50. <netui:label value="${pageInput.channel}"></netui:label>
  51. <form name="myForm">
  52. Name: <input type="text"
  53. onkeyup="ajaxFunction();" name="username"/>
  54. <input type="hidden" name="channelID" value="${pageInput.channel}"/>
  55. <textarea rows="35" cols="50" name="text">
  56. </textarea>
  57. </form>
  58. <p>output: <span id="txtHint"></span></p>
  59. </body>
  60. </html>
test.jsp looks like this:

Expand|Select|Wrap|Line Numbers
  1. <%@ page language="java" contentType="text/html;charset=UTF-8"%>
  2. <%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
  3. <%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
  4. <%@ taglib uri="http://www.bea.com/servers/portal/tags/netuix/render" prefix="render"%>
  5. <%@ page import="com.componence.repository.channel.ChannelModel"%>
  6. <%@ page import="com.componence.repository.channel.ChannelService"%>
  7.  
  8. <%
  9. Long typedvalue = Long.parseLong(request.getParameter("input"));//Long.parseLong("101");//
  10.  
  11. ChannelModel cm = ChannelService.getInstance().getChannel(typedvalue);
  12.  
  13. //System.out.println(typedvalue);    
  14. response.setContentType("text/xml");
  15. response.setHeader("Cache-Control", "no-cache");
  16. response.getWriter().write(cm.toString());
  17. %>
Sep 26 '07 #1
1 8972
dmjpro
2,476 2GB
Welcome to TSDN.
Yes it does show the whole page content.
Right now what you want?

Kind regards,
Dmjpro.
Sep 26 '07 #2

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

Similar topics

3
by: kajol | last post by:
Hi everyone I am trying to get the content of any webpage (URL) using XMLHTTP, and it is working fine for me, but suddenly I have got a URL "http://www.bizrate.com/" which is causing a system...
6
by: Nemlah | last post by:
Hello, I am working on a site which utilizes PHP/JS and the new found XMLHTTP frenzy to update dynamically. WHile the whole mechanism works beautifull, i can't get to display greek Characters...
9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
2
by: Giles | last post by:
I have a left menu that is accessed and displayed via XMLHTTP (it resides on the same server). Some sections of the web site don't have a "menu.asp", so a "Page Not Found" page is returned, which...
5
by: hatsumoto | last post by:
Hello, I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit (i.e. post) XML to a server. I can see the content of the XML response via javascript alert(xmlhttp.responseText)....
14
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
I've been searching everywhere online to find an alternative method besides using Microsoft.XMLHTTP (as it freezes the server up alot!!) but with no luck at all. I am using server side ASP, and...
3
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field...
3
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.