944,056 Members | Top Members by Rank

Ad:
Nov 2nd, 2009
0

responseText format??

Expand Post »
Hey Guys,
I am using JSP with AJAX. After a certain JSP script is processed the output is sent to the responseText. Now, I want to check what output responseText consists so that i can perform further processing. For eg, I want responseText to contain"yes" or "no" and depending on what it contains i want to execute client side script. I hope i have nt confuse you.
Similar Threads
Reputation Points: 8
Solved Threads: 13
Junior Poster
anuj576 is offline Offline
180 posts
since Jul 2008
Nov 3rd, 2009
0
Re: responseText format??
Without being able to see your code, all i can say is that u can do a comparison on the value returned by responseText, something like
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. if (responseText == "no"){
  2. //do something}else{//do something else}
Reputation Points: 36
Solved Threads: 57
Posting Whiz
Thirusha is offline Offline
355 posts
since Mar 2008
Nov 3rd, 2009
0
Re: responseText format??
This is where the problem is. On my JSP page after certain processing i wrote
out.println("Yes")
but in responseText "Yes" is not being stored so it goes into the else part.
Reputation Points: 8
Solved Threads: 13
Junior Poster
anuj576 is offline Offline
180 posts
since Jul 2008
Nov 3rd, 2009
0
Re: responseText format??
Your JSP may be serving something more than just "Yes"/"No".

Something as small as a rogue linefeed will cause a test for "Yes" or "No" aways to fail and hence drop through to the else clause.

To see what is actually served, try :-
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. alert(x.length); //it is the length you expect?
  2. //-- or
  3. alert(escape(x)); //then manually decode the result.
(where x contains the response text).

Airshow
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,527 posts
since Apr 2009
Nov 4th, 2009
0
Re: responseText format??
I used alert and the response contains the HTML tags also with "Yes" or "No".
How should i remove the HTML tags and get only "Yes" or "No"?
Reputation Points: 8
Solved Threads: 13
Junior Poster
anuj576 is offline Offline
180 posts
since Jul 2008
Nov 4th, 2009
0
Re: responseText format??
I guess your JSP is programmed to output "Yes"/"No" wrapped in an HTML tag. If so, and ifyou don't want the tag, then fix it the JSP.

I am forced to guess because to date you have posted no code.

Airshow
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,527 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: change link border
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Textbox validate





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC