Go Back   SitePoint Forums > Forum Index > Program Your Site > JavaScript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Aug 2, 2006, 23:50   #1
DuoDuo
SitePoint Zealot
 
Join Date: Mar 2006
Posts: 123
Simple if statement not working

I am using Prototype Ajax.Updater and am trying to read the response text but it doesn't seem to read. Here is a snippet of my code:
Code:
function showFormResponse(req)
{
	var response = req.responseText;
	$('message').innerHTML = req.responseText;
	if(response == '1'){
		alert('booh');
	}
}
Now var response is actually holding the exact response text when I printed it out. I don't get why the if statement is not catching the 1 even though it is shooting out that response. I am probably missing something real simple. Thanks in advance.
DuoDuo is offline   Reply With Quote
Old Aug 3, 2006, 00:31   #2
sajjad
SitePoint Zealot
 
sajjad's Avatar
 
Join Date: May 2005
Posts: 174
Removes quotes
Use this statement if(response == 1) instead of if(response == '1')
sajjad is offline   Reply With Quote
Old Aug 3, 2006, 09:06   #3
DuoDuo
SitePoint Zealot
 
Join Date: Mar 2006
Posts: 123
Wow can't believe that did it. Thanks. I assumed that when I echo the response out in php as a string then it would come back the same.
DuoDuo is offline   Reply With Quote
Old Aug 4, 2006, 02:10   #4
sajjad
SitePoint Zealot
 
sajjad's Avatar
 
Join Date: May 2005
Posts: 174
No Problem whatsoever
sajjad is offline   Reply With Quote
Old Aug 4, 2006, 20:12   #5
DuoDuo
SitePoint Zealot
 
Join Date: Mar 2006
Posts: 123
Sajjad,
How come it doesn't want to match up strings? Why only integers? I've tried matching: "Loading..." both with single quotes and double quotes. The response is exactly the same, but won't go in the if.
DuoDuo is offline   Reply With Quote
Old Aug 7, 2006, 00:10   #6
sajjad
SitePoint Zealot
 
sajjad's Avatar
 
Join Date: May 2005
Posts: 174
the answer is in ur question find it???????
sajjad is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 14:23.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved