 |
| Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Ajax 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 19th, 2007, 02:09 PM
|
|
Authorized User
|
|
Join Date: Sep 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Evaluate responseText from Server.aspx
Hi,
I need to evaluate the return result of a function from Server.aspx as following. But it doesn't work as I need
Code:
function getAjax()
{
var XmlHttp;
//Creating object of XMLHTTP in IE
try
{
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
XmlHttp = null;
}
}
//Creating object of XMLHTTP in Mozilla and Safari
if(!XmlHttp && typeof XMLHttpRequest != "undefined")
{
XmlHttp = new XMLHttpRequest();
}
return XmlHttp;
}
function GetBanType()
{
rnd++;
url = 'Server.aspx?action=GetBan&session=' + rnd ;
var re = getAjax();
re.onreadystatechange = function(){
if( re.readyState == 4 && re.status == 200 )
{
if(re.responseText != "")
{
if (re.responseText == "special value")
{
....
Actually, I call Server.aspx from many other functions as well and I set javascript control text to the return result of Server.aspx without any problem; but I cannot recognize the problem with above code.
Any idea is appreciated.
|
|

September 19th, 2007, 02:35 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Well it would help if you showed what responseText contained and how this differs from what you expect.
--
Joe ( Microsoft MVP - XML)
|
|

September 20th, 2007, 02:43 PM
|
|
Authorized User
|
|
Join Date: Sep 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the re.responseText contains:
"
<br />
<br />
<br />
<br />
<br />
<br />
"
while I expect a single word like "word" from it.
|
|

September 20th, 2007, 03:03 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Seems like a problem with your web service then. Have you tried debugging with Fiddler to see the raw request and response?
--
Joe ( Microsoft MVP - XML)
|
|

September 20th, 2007, 11:27 PM
|
|
Authorized User
|
|
Join Date: Sep 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks John for the reply!
Since I'm new to fiddler I'm not getting what's going on there.
|
|

September 21st, 2007, 02:56 AM
|
|
Authorized User
|
|
Join Date: Sep 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
finally I found the problem but not the solution.
Actually, re.responseText returns:
"Gag
<br />
<br />
<br />
<br />
<br />
<br />
"
while I'm expecting only "Gag" word.
Could I know how I can subtract only the first word of the return result?
Thanks & Regards
|
|

September 21st, 2007, 08:38 AM
|
 |
Wrox Staff
Points: 18,059, Level: 58 |
|
|
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
|
|
Peace2007: If you're still looking to learn a bit more about Fiddler, this article by Nicholas Zakas, from our Professional Ajax book ( http://www.wrox.com/WileyCDA/WroxTit...470109491.html - which Joe co-authored) might be of help:
http://www.wrox.com/WileyCDA/Section/id-303210.html
Jim Minatel
Acquisitions Director
Wiley Technology Publishing
WROX Press
Last edited by jminatel; May 18th, 2016 at 04:08 PM..
Reason: deleted dead link
|
|

September 21st, 2007, 08:47 AM
|
|
Authorized User
|
|
Join Date: Sep 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you Jim :)
|
|

January 4th, 2008, 06:47 AM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I guess the Server.aspx page has many break tags, remove those tags from the Server.aspx or after Response.Write("Gag") call Response.End()
Hope it helps.
Mujahid Khaleel
Web designing, development, E-commerce applications.
|
|
 |