• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AJAX Problem in responseText

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,
I'm new to Ajax programing.I have written a code in ajax in a jsp page but somehow
httpReq.responseText is returning the entire page.That means alert(httpReq.responseText) is returning the whole html code.Please someone help me to get a solution for this .
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SAPTARSHI CHAKRABORTY, please do us all a favor and modify your display name to not use all uppercase. It's very hard to read. Our eyes will thank you!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reponse will contain whatever gets written to it. If your Ajax request hits a server-side resource that returns an entire page, that's what responseText will contain.

Be sure that your request is only setting what you want set into the response.
[ November 01, 2007: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do have the same problem. The reponse I got is whole html page not the time what I want. I am really new to ajax. This is my first sample program. Could you please some one point me to the good tutorials.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you requesting? Your server resource can deliver just what you want it to. I don't really understand the problem. If you don't want it to return an HTML page, don't give it the URL of the HTML page.
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my html page code.

xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{

document.myForm.time.value=xmlHttp.responseText;

}
}
xmlHttp.open("GET","time.jsp",true);
xmlHttp.send(null);
}

This is my jsp code

<%Calendar currDateTemp = Calendar.getInstance();

int currDD1=currDateTemp.get(Calendar.DATE);%>


<% response.getWriter().write(currDD1);%>

Could you please let me know what I am doing wrong. I don't have any clue.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.

You can go back and change your post ot add code tags by clicking the .
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that all that's in your JSP? If it is, then there is no way that that JSP can render a complete HTML page. Why do you think that it does?
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, my complete html page is


The ok bolded in the jsp is nothing but onkeyup. The website stopping me to post onkeyup.

my complete time.jsp code is




while i start type some thing in the text box i am getting the whole time.jsp content excluding the java commands.
[ November 09, 2007: Message edited by: cathymala louis ]
[ November 09, 2007: Message edited by: cathymala louis ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ask again, if you don't want HTML markup returned as the response why are you putting it in the JSP?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
</script>
</head>
<body>
reply
    Bookmark Topic Watch Topic
  • New Topic