By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

got value of "NaN"

P: 77
hello all, i have an error value / "NaN" value that's i;m not expecting of..

this is i how i check the for the value that's become "NaN"


Expand|Select|Wrap|Line Numbers
  1. new Ajax.Request(base_url+'finance_control/cbh/recalculate_items', {postBody: Form.serialize('newcbhForm'), onComplete: function(transport) {
  2.             data = transport.responseText.evalJSON();
  3.             $('item_amount').innerHTML = data.amount;
  4.             max_cashbnknourut = parseInt(data.max_cashbnknourut);
  5.             if (isNaN(max_cashbnknourut) || isNaN(max_cashbnknourut)){
  6.                 alert("Nan error");
  7.             }
  8.         }})
the max_cashbnknourut is digit/numeric (0..10).
When i got "NaN" value, how can i make the value of max_cashbnknourut become digit/numeric again??tks

regards,

maminx
Aug 11 '08 #1
Share this Question
Share on Google+
10 Replies


gits
Expert Mod 5K+
P: 5,343
could you tell what data.max_cashbnknourut is right after the eval?

kind regards
Aug 11 '08 #2

P: 77
could you tell what data.max_cashbnknourut is right after the eval?

kind regards

yes that's right, actually i've already use that script logic to another functionality/module, and it's works well...but i have no idea when i;m using that logic/ script for another module, it's get NaN value...

help please, any idea???

when the "max_cashbnknourut" got NaN value, how can i reset the value become integer or the value of "max_cashbnknourut" after it's casting with parseInt ?
Aug 11 '08 #3

gits
Expert Mod 5K+
P: 5,343
just put an alert after the eval-line and alert data.max_cashbnknourut ... it cannot be NaN when it could be parsed to int ... may be data.max_cashbnknourut is undefined? ...

kind regards
Aug 11 '08 #4

P: 77
could you tell what data.max_cashbnknourut is right after the eval?

kind regards

//max_cashbnknourut before parsing is 1;
max_cashbnknourut = parseInt(data.max_cashbnknourut);
//max_cashbnknourut after parsing is NaN;
Aug 11 '08 #5

P: 77
just put an alert after the eval-line and alert data.max_cashbnknourut ... it cannot be NaN when it could be parsed to int ... may be data.max_cashbnknourut is undefined? ...

kind regards

the "max_cashbnknourut" is undefined when it's not cast with parseInt.
Aug 11 '08 #6

gits
Expert Mod 5K+
P: 5,343
the problem is not max_cashbnknourut that seems to be a global in your code ... but the data.max_cashbnknourut ... i assume it is just missing in your responseText ... you replace the global value 1 with an undefined value ...

kind regards
Aug 11 '08 #7

P: 77
the problem is not max_cashbnknourut that seems to be a global in your code ... but the data.max_cashbnknourut ... i assume it is just missing in your responseText ... you replace the global value 1 with an undefined value ...

kind regards

my investigation is i always got NaN value after i make parseInt of "max_cashbnknourut", before i;m casting the max_cashbnknourut, the value is 1, and after i make

max_cashbnknourut = parseInt(data.max_cashbnknourut)

the value of max_cashbnknourut is become "NaN"

idea please??
Aug 11 '08 #8

gits
Expert Mod 5K+
P: 5,343
parseInt(data.max_cashbnknourut) returns NaN in your case !!! ... so just check your Ajax-Response first! you assign NaN to your variable ... it is not a problem of parseInt ... it MUST be a problem of your Ajax-response ...

kind regards
Aug 11 '08 #9

P: 77
parseInt(data.max_cashbnknourut) returns NaN in your case !!! ... so just check your Ajax-Response first! you assign NaN to your variable ... it is not a problem of parseInt ... it MUST be a problem of your Ajax-response ...

kind regards

yes of course my problem value of NaN is only in my case, i;m sorry the problem is not in parseInt of course...

when i read your message above, i just realize that the problem is in AJAX, and i figure out the solving..it;s in controller that called the AJAX function...

anyway, thanks a lot, you had give me an idea, superb !!

kind regard, maminx
Aug 11 '08 #10

gits
Expert Mod 5K+
P: 5,343
glad to hear you found the error ... post back to the forum in case you have more questions ...

kind regards
Aug 11 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.