| 7:08 pm on Sep 1, 2011 (gmt 0)|
It will be ==
I think it only returns integers so checking for an empty string won't work.
I think you want
if(reminderresponse == 0)
if(reminderresponse == -1)
I am going from memory so I could be mistaken
| 7:42 pm on Sep 1, 2011 (gmt 0)|
OK yeah that seems to have worked, thanks!
| 8:15 pm on Sep 1, 2011 (gmt 0)|
|How do you check if http.responseText is empty or null? |
|I think it only returns integers... |
|...that seems to have worked |
I think I'm missing something, what is reminderresponse?
| 9:36 pm on Sep 1, 2011 (gmt 0)|
I assumed it was a variable that he set the http.responseText to
| 10:52 pm on Sep 1, 2011 (gmt 0)|
penders... it just hit me what you are driving at.
I read this too quick and I even typed it out and still missed it. I thought we were talking about .readyState
Pico I may have led you down the wrong path, it could be that your method is returning an integer but it isn't guarenteed. If it is truly working it was a lucky stumble.
you may want to console.log(reminderresponse) and see what it contains and make sure that == 0 is what you need
| 11:21 pm on Sep 1, 2011 (gmt 0)|
Yep, that was my confusion. reponseText (as it's name suggests) should be text/string. If the above comparison works then I would guess there is some implicit type conversion going on, and it was quite possibly a 'lucky stumble'? For instance, if reminderresponse contained the string "0", then (reminderresponse == 0) would indeed evaluate to true because of implicit type conversion.
| 2:00 am on Sep 2, 2011 (gmt 0)|
You shouldn't serve text files to your visitors, use responseXML instead.
With responseXML you should be able to check for childNodes.
Then you should be able to do something like...
...or count the number of childNodes...
Also avoid proprietary methods like innerHTML and stick to DOM methods like appendChild or importNode when importing AJAX loaded content in to a page otherwise you're going to deal with a lot of unreliable code and it's associated frustration.