SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: AJAX problem - plz help
-
Apr 10, 2007, 13:53 #1
AJAX problem - plz help
Greetings,
this is my javascript function which handles response:
function handleResponse()
{
if((http.readyState == 4)&&(http.status == 200)){
var response = http.responseText.split('|');
alert(response[0] ); // here it displays true or false it runs last condition instead of going in first or second condition
if(response[0] == 'true'){
alert("oh yes");
}else if(response[0] == 'false'){
alert("oh no");
}else{
alert("nothing");
}
}
}
when response[0] = true or false it executes last condition instead of going in first or second condition . Any idea?
Please help!
Thanks in advance
-
Apr 10, 2007, 22:23 #2
- Join Date
- Aug 2006
- Location
- India
- Posts
- 281
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Error could be on the cheking
hi
the error could be on the if loop
the value returned could be a boolean one as true or false
but you are comparing it with the string 'true' and not the boolean value true.
That could be the cause
try
if(response[0] == true){
alert("oh yes");
}else if(response[0] == false){
....
...
....
-
Apr 11, 2007, 09:03 #3
no it's string i.e "true"
Response is echoed:
echo "true"; //PHP
-
Apr 11, 2007, 21:34 #4
- Join Date
- Aug 2006
- Location
- India
- Posts
- 281
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
try === instead of ==
hi
Try using === instead of ==, i think it will work
-
Apr 12, 2007, 01:31 #5
- Join Date
- Apr 2007
- Posts
- 813
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
could that be parameter on your response function?
Code:function handleResponse(http) {
Bookmarks