473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

comparison puzzle



Hopefully the garbled first version of this post has been cancelled
- if not I apologise for it
Here is what I should have said

I am returning a value from a php file to an ajax response handler.

The php file return string might contain the string "whatever"
When I check the response text I can see it is there and I can put it
into myVariable and confirm this with an alert.

However when I do the comparison,
(myVariable=="whatever") returns false.

If instead of "whatever" I code the php file to return "42"
and then check as before
(myVariable=="42") returns false
but
(myVariable==42) returns true

I would be grateful if someone could explain what is happening here.
There is obviously something that I have not grasped.

TIA
N
May 2 '07 #1
2 1310
On May 3, 12:58 am, noddy <n...@toyland.comwrote:
Hopefully the garbled first version of this post has been cancelled
- if not I apologise for it
Here is what I should have said

I am returning a value from a php file to an ajax response handler.

The php file return string might contain the string "whatever"
When I check the response text I can see it is there and I can put it
into myVariable and confirm this with an alert.

However when I do the comparison,
(myVariable=="whatever") returns false.

If instead of "whatever" I code the php file to return "42"
and then check as before
(myVariable=="42") returns false
but
(myVariable==42) returns true

I would be grateful if someone could explain what is happening here.
There is obviously something that I have not grasped.

TIA
N
if you intend to always compare as a string why not use typing
myVariable.toString() == "42"

May 3 '07 #2
On 2 May 2007 21:59:39 -0700, shimmyshack <ma********@gmail.com>
wrote:
>On May 3, 12:58 am, noddy <n...@toyland.comwrote:
>Hopefully the garbled first version of this post has been cancelled
- if not I apologise for it
Here is what I should have said

I am returning a value from a php file to an ajax response handler.

The php file return string might contain the string "whatever"
When I check the response text I can see it is there and I can put it
into myVariable and confirm this with an alert.

However when I do the comparison,
(myVariable=="whatever") returns false.

If instead of "whatever" I code the php file to return "42"
and then check as before
(myVariable=="42") returns false
but
(myVariable==42) returns true

I would be grateful if someone could explain what is happening here.
There is obviously something that I have not grasped.

TIA
N

if you intend to always compare as a string why not use typing
myVariable.toString() == "42"
Thanks for that suggestion Matt
May 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Developwebsites | last post by:
Hi all, I've made a sliding puzzle game in shockwave which works just fine, except I dont know how to have it solve itself. the URL is: http://members.aol.com/rglukov/games/selfsolve.htm ...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
0
by: xavier vazquez | last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
5
by: ashish0799 | last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM Jigsaw puzzles. You would have solved many in your childhood and many people still like it in their old ages also. Now what you have got to do...
3
by: oncue01 | last post by:
Word Puzzle Task You are going to search M words in an N × N puzzle. The words may have been placed in one of the four directions as from (i) left to right (E), (ii) right to left (W), (iii) up...
6
by: Phoe6 | last post by:
Hi All, I would like to request a code and design review of one of my program. n-puzzle.py http://sarovar.org/snippet/detail.php?type=snippet&id=83 Its a N-puzzle problem solver ( Wikipedia page...
2
by: Gio | last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book? And while I'm there, should I get the Puzzle Book? Or should I save the Puzzle Book for when I'm more advanced? - Gio ...
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
5
by: dmf1207 | last post by:
Hi All! I'm new to javascript and need a little help with a simple puzzle im trying to design. I have a 600x100 pixel picture that I have sliced into 6 100x100 rectangles making a table of of 6...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.