responseText format??

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2008
Posts: 147
Reputation: anuj576 is an unknown quantity at this point 
Solved Threads: 10
anuj576 anuj576 is offline Offline
Junior Poster

responseText format??

 
0
  #1
29 Days Ago
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.
Thanks & Regards,
Anuj Sharma
Future Software Engineer
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 317
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 51
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz
 
0
  #2
28 Days Ago
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}
Life... Is a Moment
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 147
Reputation: anuj576 is an unknown quantity at this point 
Solved Threads: 10
anuj576 anuj576 is offline Offline
Junior Poster
 
0
  #3
28 Days Ago
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.
Thanks & Regards,
Anuj Sharma
Future Software Engineer
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 836
Reputation: Airshow is on a distinguished road 
Solved Threads: 120
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #4
28 Days Ago
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
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 147
Reputation: anuj576 is an unknown quantity at this point 
Solved Threads: 10
anuj576 anuj576 is offline Offline
Junior Poster
 
0
  #5
27 Days Ago
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"?
Thanks & Regards,
Anuj Sharma
Future Software Engineer
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 836
Reputation: Airshow is on a distinguished road 
Solved Threads: 120
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #6
27 Days Ago
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
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC