Click here to Skip to main content
15,394,162 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Javascript CSP and CORS problem? How can I send Cookies with AJAX in CORS? Pin
Member 1510027615-Mar-21 7:56
MemberMember 1510027615-Mar-21 7:56 
GeneralRe: Javascript CSP and CORS problem? How can I send Cookies with AJAX in CORS? Pin
Richard Deeming15-Mar-21 22:31
mveRichard Deeming15-Mar-21 22:31 
GeneralRe: Javascript CSP and CORS problem? How can I send Cookies with AJAX in CORS? Pin
Member 1510027616-Mar-21 6:49
MemberMember 1510027616-Mar-21 6:49 
Questionif statement not working Pin
chizzy4211-Mar-21 7:53
Memberchizzy4211-Mar-21 7:53 
AnswerRe: if statement not working Pin
NotTodayYo11-Mar-21 8:24
MemberNotTodayYo11-Mar-21 8:24 
AnswerRe: if statement not working Pin
W Balboos, GHB11-Mar-21 8:45
mveW Balboos, GHB11-Mar-21 8:45 
GeneralRe: if statement not working Pin
chizzy4213-Mar-21 4:03
Memberchizzy4213-Mar-21 4:03 
GeneralRe: if statement not working Pin
Member 1510027615-Mar-21 8:15
MemberMember 1510027615-Mar-21 8:15 
Two things I think you need to focus on learning: Console Log, and Typeof.

Javascript has a few primitive types of variables. It looks like you started going back and forth with int coming up as strings. I saw you put in parseInt which is what you need. What else may help is instead of putting things out to a browser element, you can access them with the Console.

Console = press F12 and look at the "Console". (Except IE because IE still sucks)

So you can try your first one with this:

JavaScript
console.log("Hello World")


This is rather important as next thing to try to see if a value is an Integer or not is this:

JavaScript
console.log(typeof myVar)


That should tell you Integer or String or Array. If you try to add a String to an Integer you get a hybrid and the Int is converted to a string.

JavaScript
var myVar = "Hello" + 12345;
console.log(myVar);

The output of that will be "Hello12345" Happens with Numbers also, which is when you end up with NaN or "Not a Number" which can be checked with "isNaN(var)".

So lets say you have this:

JavaScript
var varA = 10;
var varB = "20";
var sum = varA + varB;


Did you notice the quotes on varB? It means that although there are numeric characters in it, the variable is treated like a String, which causes varA to be typecast to a String. Your output there would be "1020" not the 30 like you expect.

Back to the console for just a moment. If you need to check the value of a variable or object or something in your code without jumping thru a thousand hoops to even see what that is, you can "LOG" that. In the console you can type your variable name. Simply type "varA" without the quotes and the console will output whatever the VALUE of varA is. You can also try putting in "typeof varA" (again, no quotes) and see if the VALUE is an integer or string, which is where I think you have the most trouble!

It doesnt fix your problem, but I hope this helps to undestand what the problem is and some of the tools you have available to you!
GeneralRe: if statement not working Pin
chizzy4217-Mar-21 2:28
Memberchizzy4217-Mar-21 2:28 
QuestionBeginner 5 Project idea Pin
Member 1373246628-Feb-21 14:29
MemberMember 1373246628-Feb-21 14:29 
AnswerRe: Beginner 5 Project idea Pin
Richard MacCutchan28-Feb-21 21:37
mveRichard MacCutchan28-Feb-21 21:37 
AnswerRe: Beginner 5 Project idea Pin
Scott Butchers19-Mar-21 3:26
MemberScott Butchers19-Mar-21 3:26 
QuestionHow to navigate to next search term in angular with up and down arrow buttons? Pin
shruti devurkar18-Feb-21 5:54
Membershruti devurkar18-Feb-21 5:54 
SuggestionRe: How to navigate to next search term in angular with up and down arrow buttons? Pin
CHill6018-Feb-21 5:55
mveCHill6018-Feb-21 5:55 
QuestionTrying to read a value that is coming from html() function from Table Cell Id Pin
simpledeveloper17-Feb-21 19:42
Membersimpledeveloper17-Feb-21 19:42 
AnswerRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
Richard MacCutchan17-Feb-21 21:38
mveRichard MacCutchan17-Feb-21 21:38 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
simpledeveloper17-Feb-21 21:59
Membersimpledeveloper17-Feb-21 21:59 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
Richard MacCutchan17-Feb-21 22:45
mveRichard MacCutchan17-Feb-21 22:45 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
simpledeveloper17-Feb-21 22:47
Membersimpledeveloper17-Feb-21 22:47 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
Richard MacCutchan17-Feb-21 23:11
mveRichard MacCutchan17-Feb-21 23:11 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
simpledeveloper18-Feb-21 7:08
Membersimpledeveloper18-Feb-21 7:08 
GeneralRe: Trying to read a value that is coming from html() function from Table Cell Id Pin
Richard MacCutchan18-Feb-21 21:19
mveRichard MacCutchan18-Feb-21 21:19 
QuestionSending Blob (webm) from client to server. Pin
Rayj201010-Feb-21 12:38
MemberRayj201010-Feb-21 12:38 
Questionconnecting javascript or jquery with node.js backend APIs Pin
Member 141035569-Feb-21 10:25
MemberMember 141035569-Feb-21 10:25 
QuestionEdit only a part of text inserted in a "select"... Pin
Member 150649448-Feb-21 23:46
MemberMember 150649448-Feb-21 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.