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.

Recommended Answers

All 5 Replies

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

if (responseText == "no"){
//do something}else{//do something else}

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.

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 :-

alert(x.length); //it is the length you expect?
//-- or
alert(escape(x)); //then manually decode the result.

(where x contains the response text).

Airshow

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"?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.