 |
BOOK: Professional Ajax ISBN: 978-0-471-77778-6  | This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786 |
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url] |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

September 23rd, 2006, 06:14 AM
|
Registered User
|
|
Join Date: Apr 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ajax + Java (Jsp)
Hi Dear all.......
i am new to ajax. I am doing an application in ajax + jsp. In my client side i have
a html file called Ajax_Client.html
and one jsp file getDescription.jsp.
I am giving the content of two files...
Ajax_Client.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> 1st Ajax Application</title>
<script >
function getDescription(channelId,itemId)
{
var url = 'http://localhost:8084/Aajax/getDescription.jsp?channelId=' + channelId + '&itemId=' + itemId;
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = processRequest;
req.open("GET", url, true);
req.send(null);
}
function processRequest() {
if (req.readyState == 4) {
alert ( "Hyee Nigam.... req.readyState="+req.readyState+" And req.status="+req.status+" is Comming form the Server" );
if (req.status == 200) {
parseMessages();
} else {
alert ( "Hyee Nigam.... Not able to retrieve description" ); }
}
}
function parseMessages() {
alert ( "Enter to the parseMessages() function" ); //--Just to print only, to check upto which line function is executing
response = req.responseXML.documentElement;
alert ( "Execution of 'response = req.responseXML.documentElement;' " ); //--Just to print only, to check upto which line function is executing
itemDescription = response.getElementsByTagName('description')[0].firstChild.data;
alert ( "Execution of 'itemDescription = response.getElementsByTagName('description')[0].firstChild.data;' " ); //--Just to print only, to check upto which line function is executing
alert ( itemDescription ); //-- To show the content from the server
alert ( "Execution Completed" );
}
</script>
</head>
<body>
<a href="/" onmouseover="getDescription(3,1)">My 1st Ajax Application<a>
</body>
</html>
getDescription.jsp
<html>
<body>
<%
String channelId = request.getParameter("channelId");
String itemId = request.getParameter("itemId");
//String description = new Channel(channelId).getItemDescription(itemId);
String description = "This is the description for the channelId: " + channelId + "and itemId: " + itemId;
if (description != null) {
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write("<description>" + description.toString() + "</description>");
} else {
//nothing to show
response.setStatus(HttpServletResponse.SC_NO_CONTE NT);
}
%>
</body>
</html>
i think its problem in the function parseMessages() in Ajax_Client.html page
Thanks
Thanks & Regard
Nigamananda Rout
|

September 23rd, 2006, 06:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
So what's the problem? Does parseMessages() get called? What's the last alert message you get?
--
Joe ( Microsoft MVP - XML)
|

September 25th, 2006, 11:33 AM
|
Registered User
|
|
Join Date: Apr 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi...
Yes... parseMessages() method is called...and going upto
alert("Execution of 'response = req.responseXML.documentElement;'" );
but showing error in line
itemDescription = response.getElementsByTagName('description')[0].firstChild.data;
Thanks & Regard
Nigamananda Rout
|

September 26th, 2006, 02:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Heaven forfend that anyone ever posts an error message...
Try navigating to 'http://localhost:8084/Aajax/getDescription.jsp?channelId=<validId>&itemId=<val idId> to make sure your XML is being returned.
Try alerting req.responseText to see if there's any content.
Post the output of responseText here and the error message if it's still failing.
You could also try using a more up to date class such as MSXML2.XmlHttp.3.0.
--
Joe ( Microsoft MVP - XML)
|

October 10th, 2006, 01:06 AM
|
Registered User
|
|
Join Date: Apr 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi...
i tried but not getting sucess....
Can u give me a sample code of a very simple application.... to which i can run and will try to know about it...
You can mail me on nigam.anand@geetup.net
Thanks & Regard
Nigamananda Rout
|

October 10th, 2006, 02:28 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
I refer to my previous post. I am trying to help but you failed to any of the things I asked...
--
Joe ( Microsoft MVP - XML)
|

January 18th, 2007, 12:19 PM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi nigam,
I know what is the problem.
see when your XML is not proper (having reserved words like &, ", °, etc.)
in that case you must have to replace them with html codes.
replace & with &, " with " etc.
that may solved the problem. still you find error then that means there is having some special character in your XML String which is not suppose to be there.
Only solution I have for that is replace that character with HTML code.
Is any one know how can I completely get out of this problem
|
|
 |