Search the Community
Showing results for tags 'javascript'.
-
i learnt java and c++ a few years ago but stuck oop, i never made a gui application for example, i tried some people's project, when i ran it into my netbeans, there were so many errors, but i want to learn javascript right now, i think i am able to run it in console / command prompt but seriously, why does the syntax look so different when it comes to oop / gui application. where i can a fully guide e-book for idiot like me ? (i read javascript for dummies e-book, but i couldnt find oop examples) thank you
-
No matter how I try I can't get the single digit dates to match with statements, if's or anything else. var jsDate = new Date(arrayJson["Date"]); var jsDate = jsDate.getDay(); alert("Looking for day: " + jsDate); switch(jsDate){ case "6": // Saturday jsDate.setDate(jsDate.getDate() + 2); alert("Saturday"); break; case "0": // Sunday jsDate.setDate(jsDate.getDate() + 1); alert("Sunday"); break; case "1": // alert("Monday"); break; case "2": // alert("Tuesday"); break; case "3": // alert("Wednesday"); break; case "4": // alert("Thursday"); break; case "5": // alert("Friday"); break; default: alert("Default"); } alert("Date is: " + jsDate.toLocaleDateString("en-GB")); I've gotta have missed something simple and privative. Alerts work fine and I can tell what I'm looking for, just the cases and if's never match, as if the single digit number isn't a single digit nor a string or int that can be matched against, just always goes into default case.
-
Run into a problem where I need a function that is outside the document.ready to call a function that is inside it. $(document).ready(function () { function ExampleDoStuff(var message){ alert(message); } }); function CalledExternally(){ ExampleDoStuff("Do Stuff"); } Ideally I'd have everything inside the ready script but I need the other function to be called by a different JS file, that also exists on the browser page, I couldn't call it if it was inside the scope of ready but could if it was outside. I can think of two fixes: How can I place CalledExternally inside the ready and for it to be easily called by different JS files without the files explicitly referencing THIS file? If not, how can I get the code above to work. Online says to make the ready an class, doesn't work so I guess I keep doing it wrong?
-
I'm unsure if I should study AWS or Azure. In my city in Sweden I find 200 jobs for AWS and 350 for Azure on the job database. I'm new to programming and only know Python and Java at high school level for reference. If I study AWS I will study Java and if I choose Azure I will study C# and basic Javascript. Do any of you have a suggestion on which cloudplatform to choose? Searching videos on YouTube it seems as if there's more videos on Java but perhaps it doesn't matter. I found BroCode to be excellent to learn basics for Python and Java. Update: I choose to study Azure. There's more job for Azure in Sweden and acording to an Azure consultant based in Sweden, most companies are centered around the Microsoft products; AD, AAD, Office 365 and Azure. The companies he meet that have a footprint in AWS are mostly looking to migrate to Azure.
- 15 replies
-
- cloud computing
- aws
-
(and 4 more)
Tagged with:
-
I take in json data that I want to go through and use the fields that I need. Data looks like this { "Part1": { "Field_1": { "Type": "", "Name": "", "special": "" }, "Field_2": { "Type": "", "Name": "", "special": "" }, "Field_3": { "Type": "", "Name": "", "special": "" }, "Field_4": { "Type": "", "Name": "", "special": "" }, "Field_5": { "Type": "", "Name": "", "special": "" }, "Field_6": { "Type": "", "Name": "", "special": "" }, "Field_7": { "Type": "radio", "Name": "RadioDefault", "special": "for" }, "Field_8": { "Type": "radio", "Name": "RadioDefault", "special": "for" }, "Field_9": { "Type": "radio", "Name": "RadioDefault", "special": "for" } }, "Part2": { "Field_1": { "Type": "", "Name": "", "special": "" }, "Field_2": { "Type": "", "Name": "", "special": "" }, "Field_3": { "Type": "", "Name": "TargetID38", "special": "rows=\"2\"" }, "Field_4": { "Type": "", "Name": "", "special": "" }, "Field_5": { "Type": "", "Name": "", "special": "" }, "Field_6": { "Type": "", "Name": "", "special": "" } } } I've parsed the whole json into an object certElementData = Object.entries(JSON.parse(result)); And tried to loop through the data. Getting unlucky here. Maybe I should go back to simple for loops but I want to try out the for in and for of loops. For of loops do well until I get to the Field_'s part as that refuses to go into a array and stays being an object. If I try to use a for in loop, that loop will wipe any following data, saying that sure it'll now loop through to Field_9 but that's it, there's no data after it. How can I retain all the data yet get to the bottom info such as "Name":"" and "Type":"" that I need. Have a look at the initial start parse as well. What if I'm needlessly parsing them and made a mistake at the start? Thanks.
-
Got a simple field <label for="comment">Text here</label> <textarea class="form-control" rows="2" id="comment" name="ID1"></textarea> and I want to get label text. I can easily get the field value with elementByID as well as jQuery .val() but no luck getting to the label and the text that is in there. In theory should be pretty simple, I've gotta be forgetting something.
-
Delete this before posting. Please make sure to include the language that you're using in the title, and use the <> button for any code. I have a modular table, its size depending on the array that makes it. Its ID would look something like "AA[0][1][A]" Haven't found anything that I can pinpoint at but it seems like jQuery doesn't like arrayed ID's. My normal ID's work when jQuering like alert($("#I001").val()); but the moment try to do it in the form of my array ID it's a dud. I've tried alert($("#AA[0][1][A]").val()); As well as var IDValue = "AA[0][1][A]"; alert($("#" + IDValue).val()); And still nothing. Everything always comes back as "undefined." Feels like an amateurish mistake but it's hooked me and I can't let go. I need to know why my jQuery isn't working, well the array ID at least, normal ID is fine.
-
I'm going to study 2 year in programming and I'm unsure what to choose. The educations I'm choosing between are one called "Front End Developer" and "Cloud Developer (Azure)". Azure are more popular in my country than AWS since most companies are centered around the Microsoft products; AD, AAD, Office 365 according to a consultant. Here's the courses in the included in these two educations: Cloud Developer (Azure) course content: Basic Concepts in Object-Oriented Programming Programming Language C# & Visual Studio Object-Oriented Analysis & Modeling with UML APIs and their structure The .NET Platform & .NET Core Application Development in C# .NET HTML5, CSS3 & Fundamentals of JavaScript Frameworks (React/Angular) & Web Security Azure Platform and Portal & Azure App Services Automating Azure with Azure CLI Cloud Databases & Cloud Storage Development Models: Waterfall, Agile, DevOps ASP.NET Core & Service Fabric Front End Developer course content: Web Development: Frontend Basic JavaScript Programming Web Communication User Experience and Interaction Design Web Frameworks for JavaScript Agile Project Methodology Advanced Web Development with JavaScript Packaging, Delivery, and Follow-up Specialization: Frontend, UX/UI From seeing these courses, what do you think are the benefits and disadvantages between these educations? I'm especially thinking about from stress, work life balance, amount of jobs etc.
- 12 replies
-
- cloud computing
- azure
-
(and 2 more)
Tagged with:
-
To keep code simple and scalable, I'm hoping there's a way to list multiple classes inside jQuery events. I've got 3 inputs I want to have code listen to. I've tried: $('.table_1','.table_2','.table_3').on('focusout', function () { // alert("multi on focusout"); }); and $('.table_1 .table_2 .table_3').on('focusout', function () { // alert("multi on focusout"); }); I feel like I'm close and this is the way it's meant to work in functionality, I just don't have the proper identifiers to let jQuery know I'm listing multiple classes into one event. What is the correct way of identifying this?
-
So I have a form, using some radio buttons for mutually exclusive selection. Radio buttons are great as I can simplify code (basically not write any code for it) as they do exclusivity automatically. All is great except field serialization. I send off my form data, it saves the radio fields under a single name by which they are all grouped under, I can't give each a unique name otherwise their radio function stops working. Problem is, if I have 3 choices the only serialized data might be: "flexRadioDefault":"1" ...good luck me finding out which one of the 3 was selected. My only brainstorm solution is to actually send off the button ID inside the "value" which I could reference later? Instead of "1" here could be "flexRadioDefault":"ID1 to 3." For documentation and form loading. What would be the best way to sort this out? Am I good to try and figure out how to cross reference which radio button was selected with sending the ID inside value or am I overcomplicating things not aware that there's an easy solution?
- 5 replies
-
- html
- javascript
-
(and 2 more)
Tagged with:
-
I was testing node.js to see if I can implement it in my Websites. In the node.js file root directory I have installed the cookie-parser module for some values in another js file. I added the html file and the other js file but when I open the html page on my browser , it shows cannot get null. Please Help stuck in development of website Thanks in advance
-
- node.js
- javascript
-
(and 1 more)
Tagged with:
-
Hello, I'm making a web-app-store but I can't seem to figure out a bit of custom code required to show the client paid for content and some other things. (JavaScript) Please keep in mind this is from an absolute noob perspective. I don't know any code or definitions beyond what || and && mean. I have a Wordpress page comparable to a Pokédex. It's supposed show a grayed out image of a pokémon for visitors but when someone aquires a license key from Gumroad it's supposed to show a swipeable image gallery. The code has to check for 2 licenses on Gumroad's servers. And as long as at least 1 is active, it has to show the image gallery. Here is Gumroad's explanation for checking a license: https://help.gumroad.com/article/76-license-keys curl https://api.gumroad.com/v2/licenses/verify \ -d "product_permalink=QMGY" \ -d "license_key=YOUR_CUSTOMERS_LICENSE_KEY" \ -X POST ^Here I have to fill in info about the product to check for. Then it gets back a response that looks like this, or a 404 error: { "success": true, "uses": 29, "purchase": { "seller_id": "kL0paVL1SdmJSYRNs-OCMg==", "product_id": "32-nPAinqpLj0B_WIwVlMw==", "product_name": "license product", "permalink": "testprod1", "product_permalink": "https://gum.co/testprod1", "email": "sample@example.com", "price": 0, "gumroad_fee": 0, "currency": "usd", "quantity": 1, "discover_fee_charged": false, "can_contact": true, "referrer": "direct", "card": { "bin": null, "expiry_month": null, "expiry_year": null, "type": null, "visual": null }, "order_number": 524459995, "sale_id": "FO8TXN-dvxYbBdahG97Y-Q==", "sale_timestamp": "2021-01-05T19:38:56Z", "purchaser_id": "5550311507811", "subscription_id": "GDzW4_NBdQy-o7Gjjng7lw==", "variants": "", "license_key": "85DB262A-C19D4B06-A5335A6B-8C079166", "ip_country": "India", "recurrence": "monthly", "is_gift_receiver_purchase": false, "refunded": false, "disputed": false, "dispute_won": false, "id": "FO8TXN-dvxYbBdahG97Y-Q==", "created_at": "2021-01-05T19:38:56Z", "custom_fields": [], "subscription_cancelled_at": "2021-02-05T20:09:27Z", "subscription_failed_at": null } } The conditional branch has to look for the succes = 'true' value, then it'll show the image gallery. Although, I don't know for sure if the succes value is for an active license or just for retrieving requested information. If refunded = true or succes = false it's supposed to be the grayed out image. I have 4 questions / problems: 1. How do I do the license check, let alone 2? Just paste it above the branch and the code as raw JavaScript on the gallery spot of the page? (I'm using a visual composer) 2. How do I connect the license check with the conditional branch or how do I pull info from that response? 3. Can I make it so only the paid for content gets retrieved from the server when the license is "ok"? (To prevent cache ripping or something like that.) 4. (Bonus) When you try to screenshot in your bank app, the screenshot is completely black. How do I do this? I came as far as putting this script on the page but it doesn't work: <span style="color: #1a1a1a;">if (e.keyCode == SYSQR) {</span> <span style="color: #1a1a1a;">filter:alpha(opacity=0);</span> <span style="color: #1a1a1a;">}</span> License checking script on page right now: <p>curl https://api.gumroad.com/v2/licenses/verify \ -d "product_permalink=QMGY" \ -d "license_key=YOUR_CUSTOMERS_LICENSE_KEY" \ -X POST </p> //Response from Gumroad's server comes here I guess, idk how to do this// if ('succes' = true) { echo <p>[vc_row][vc_column][us_image_slider ids="1868,432,87" css="%7B%22default%22%3A%7B%22background-image%22%3A%222237%7Cfull%22%2C%22background-position%22%3A%2225%25%22%2C%22background-size%22%3A%22cover%22%2C%22background-repeat%22%3A%22no-repeat%22%2C%22background-attachment%22%3A%22fixed%22%2C%22border-radius%22%3A%228px%22%7D%7D"][/vc_column][/vc_row]</p>; else if ('refunded' = true || 'succes' = false) { <p>[vc_row][vc_column][us_image image="607"][/vc_column][/vc_row]</p> } } Thanks in advance!
- 5 replies
-
- javascript
- wordpress
-
(and 1 more)
Tagged with:
-
My code: events: { onPlay: function(e) { document.getElementById('theatermode').addEventListener('click', async function() { var t = { a: document.querySelectorAll('.bn35')[0], b: document.querySelectorAll('._1OVBBWLtHoSPfGCRaPzpTfe ')[0], } if (t.a.classList.contains("t2heater")&& t.b.classList.contains("t2heater")) { t.a.style.cssText = '' t.b.style.cssText = '' t.a.classList.remove("t2heater") t.b.classList.remove("t2heater") }else{ t.a.classList.add("t2heater") t.b.classList.add("t2heater") if (!t.a.classList.contains("t2heater") && !t.b.classList.contains("t2heater")) { t.a.classList.add("t2heater") t.b.classList.add("t2heater") } t.a.style.cssText = 'padding-left:15%;padding-right:15%' t.b.style.cssText = 'width:70% !important;' } }) } } Page markup: --title--- <div class= _1OVBBWLtHoSPfGCRaPzpTfe> <video loaded/ready =events.onplay.... > <div class=bn35> For some reason, the code above only fires Sometimes. The click does work, But the classList and csstext do not work, In google chrome, the DIVs flash (showing a change) but still not class or CSS text. help? These events are linked to my video player
-
On Desktop, it works fine, but on mobile, the mobile-keyboard closes for no reason <video> Untitled Project2.mp4 sorry about the video "edits" it was kinda rushed, and didnt take the time to do it cleanly here is all the source code for the editor https://git.nrrinc.net/CLeditor-3.6 (note: this was built for jquery 1.3, but it was updated to work with Jquery 3.6) could anyone point me in the right way to fix this bug?
-
Hey all. The program that I am currently taking contains a web development course and I have no idea about the workflow or tools involved with it. All that we're dealing with this semester is JS, CSS/HTML, AJAX and JSON so nothing too crazy (Next semester is server side stuff). I am extremely familiar when it comes to the workflow and toolchains of compiled/interpreted applications using languages like C/C++, Java, C#, Python, ASM but web development is extremely far out of my wheel house so I have no idea what tools and workflows are available for it. So far my setup is VS code with a live server extension and chrome but after using this for nearly 3 months out of this semester it still feels clunky to design and test web pages. I find it counter intuitive to have to reload the page every time I make a change, especially when I am working with forms and have to program the functionality for them. When I am working on the pages it is very iterative. I'll get the elements on the page and then program the required functionality for them before I style the page. But as I make changes I am constantly reloading and testing these changes, It helps in the long run making sure the page functions exactly as I want it too so that I get excellent grades but it is also a massive time sink to do so. The way I see it, I have 4 possible options. Change my workflow Change my tooling to benefit my work flow A mixture of the two above choices. Just live with it. Any thoughts for improving my workflow or toolchain? It would be great to have WYSIWYG (What you see is what you get) type of editing so that I can make changes on the fly without having to go through the process of retesting the entire page but rather just the section I need to retest. Additionally, I find the debugging experience to be lack luster at best; although, that might just be my naivety when using chromes developer tools.
- 3 replies
-
- web
- javascript
-
(and 2 more)
Tagged with:
-
So the company that I'm working for is switching to web based software for a lot of my work. Previously we had used a desktop software that allowed keyboard shortcuts to navigate the entire interface without ever touching the mouse and I fell in love with this style of using the computer because of how fast it is. Well with the new software I am much slower and have been looking into extensions to allow me to accomplish this within the web app. One option I found was the extension Vimium. It is essentially perfect except for one major flaw. From what I've been able to find it can't interact with javascript elements on pages. Is there a way to make it work with that? Or, is there an alternative program that operates the same way?
- 3 replies
-
- javascript
- vimium
-
(and 1 more)
Tagged with:
-
I am looking forward on earning income from programming, I have a very very basic knowledge in Popular languages, But haven't excelled in anyone. I wish to master either Python or JavaScript... The thing I worries about JS -- A lot of Frameworks and Libraries to keep Up with The things I worry about Python -- A lot of people mastered it, worried that that may reduce the demand -- I am not actually sure what will I do as Freelancing Project if I master Python.
- 3 replies
-
- programming
- python
-
(and 1 more)
Tagged with:
-
What I am trying to build is a JavaScript timer that when done the button appears which I have done. But on click of the button I would like to add 90 days to the timer and start it again but am having trouble doing this. <div class="card" style="width: 20rem;"> <div class="card-body"> <h5 class="card-title">226 manually greased zerks</h5> <h6 class="card-subtitle mb-2 text-muted">3 Month timer</h6> <ul class="nav"> <li class="nav-item"> <a class="nav-link active" href="#"><h5 id="days"></h5></a> <li class="nav-item"> <a class="nav-link" href="#"><h5 id="hours"></h5></a> <li class="nav-item"> <a class="nav-link" href="#"><h5 id="mins"></h5></a> <li class="nav-item"> <a class="nav-link" href="#"><h5 id="secs"></h5></a> </ul> <br> <p class="card-text"> <button type="button" id="success" onclick="myFunction()" class="btn btn-success">Complete <i class="fas fa-check"></i></button> </div> </div> <script> // The data/time we want to countdown to var countDownDate = new Date("Oct 31, 2020 14:55:10").getTime(); // Run myfunc every second var myfunc = setInterval(function() { var now = new Date().getTime(); var timeleft = countDownDate - now; // Calculating the days, hours, minutes and seconds left var days = Math.floor(timeleft / (1000 * 60 * 60 * 24)); var hours = Math.floor((timeleft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((timeleft % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((timeleft % (1000 * 60)) / 1000); // Result is output to the specific element document.getElementById("days").innerHTML = days + "d " document.getElementById("hours").innerHTML = hours + "h " document.getElementById("mins").innerHTML = minutes + "m " document.getElementById("secs").innerHTML = seconds + "s " setInterval(function() { if(timeleft > "0") document.getElementById("success").style.display="none"; }); // Display the message when countdown is over if (timeleft < "0") { clearInterval(myfunc); document.getElementById("days").innerHTML = "0" + "d " document.getElementById("hours").innerHTML = "0" + "h " document.getElementById("mins").innerHTML = "0" + "m " document.getElementById("secs").innerHTML = "0" + "s " document.getElementById("success").style.display = "inline"; document.getElementById("days").style.color = "#FF0000"; document.getElementById("hours").style.color = "#FF0000"; document.getElementById("mins").style.color = "#FF0000"; document.getElementById("secs").style.color = "#FF0000"; } }, 1000); </script>
-
I've been trying at this for about 30 minutes looking for a solution. I've restarted my laptop about 2 times but the "solutions" I found on google were very complicated and it seemed like not a lot of people knew about this. That's when I remember that LTT has a forum, so I joined it like a couple of minutes ago asking for your technological help :D also the name sharon is just my aunt that wanted this laptop borrowed for covid, so I took it to a store to have it wiped and name change so that I can give it to her but she doesnt need it anymore D:
- 2 replies
-
- javascript
- npm
-
(and 3 more)
Tagged with:
-
I am trying to convert an html website into one made entirely of JavaScript and CSS. However, I am having trouble linking an image to a URL in JS. Here is the code I'm having trouble with: var a = document.createElement('a'); var img = document.createElement('img'); a.href = "Html.html"; img.appendChild = "a"; img.src = "logo.png"; img.title = "Daring Fireball: Home";; img.id = "logo"; img.alternate = "Daring Fireball" img.height = "56" img.href = "Html.html"; document.body.appendChild(img);
-
Node.js 15.0.0 is released and along with Node.js, npm also got a new update and now it's npm 7. npm 7 comes with many new features - including npm workspaces and a new package-lock.json format. npm 7 also includes yarn.lock file support. One of the big changes in npm 7 is that peer dependencies are now installed by default. ---------------------------------------------- Summary Node.js released Node.js 15.0.0 on 20 Oct, 2020. It comes with a lot of new things and a few things are purged. npm also got a new update and released as npm 7. Sources https://nodejs.org/en/blog/release/v15.0.0/
-
Hi Team I have a magic mirror install, with a calendar module installed The problem is the module doesn't have overflow functionality (if there are too many events for a day it just puts a +1 or +2 etc at the bottom of the list I looked at the support for it and the dev doesnt want to add any scrolling features as its too much for a raspberry pi to handle (apparently) and even those of us who dont use it on a pi (myself) he wont support Iv been looking into the code and so far have been able to use css to detect which divs have overflowed events, and put a scroll tag on that div What im trying to figure out now is how to animate those divs Iv looked as css animations and jquery animations, but this is where im stuck trying to figure out A) how to get the divs with the scroll tag to animate (as it changes when more events are added or removed_ B) How to control the speed based on the number of events hidden C) how to loop the animation so it goes back to the start and repeat when it gets to the end Is anyone willing to give me some help or at least point to some online documents which would help? many thanks in advance
-
- javascript
- jquery
-
(and 2 more)
Tagged with:
-
So I have JS code at the top of the page mixed in with HTML. After the HTML is done I have a button with a separate <script> opening as it doesn't like code to be above it. Looks something like this: <script> declare variables var examplevar = 100; all functions </script> <button>on clic= Dofunctiononclick()</button <script> function Dofunctiononclick(){ alert(examplevar); } </script> but now that the script block was broken apart it's unable to reference what examplevar is, it's undefined because it's in a separate block above my button. A super simple fix, an amateur mistake but it's been such a long day my brain doesn't function anymore.
-
Needed a searchable select dropdown box and found a TomSelect library that has it all set up. I added in the required library. More specifically, this solution here. <link href="https://cdn.jsdelivr.net/npm/tom-select@2.0.0-rc.4/dist/css/tom-select.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/tom-select@2.0.0-rc.4/dist/js/tom-select.complete.min.js"></script> added in the JS code new TomSelect("#select-state",{ create: false, sortField: { field: "text", direction: "asc" } }); and everything works fine as intended until I realised that TomSelect filters out my text in said HTML dropdown selection. If one of my dropdown selection was meant to say: 1 - this is option "hello" then after implementing the TomSelect, it says instead this is option I assume filtering out elements before and after keys like - and ". Would love to know to disable this filter, or at least modify it so that the whole text of the option is displayed otherwise the point of a dropdown is sort of defeated. I was thinking of maybe tackling the attributes such as "field: "text"" but I have no idea where to begin or what other options could be. What would these SortField option be?
-
As a way to expand my skill set and give me something to do in my spare time on programming, I've taken up learning what is called full stack web development. In it's most high level description, that means dabbling in both the front-end (client app, web page, etc.) and back-end (server, database, etc.) of the development process. To ease going into this, because I didn't want to learn almost a half-dozen languages, I've stuck with Node.js and MongoDB, as both use ECMAscript. Essentially all that means is I have to learn JavaScript. This has been a key point in where I'm going with the title. A full web application is made up of several independent pieces Pieces like the server, the database, the client, and others. These pieces are independent form each other, yet they still need to talk to each other and perform as a cohesive unit. If one of these breaks or isn't developed well, the whole application can have a bad time. Multi-threading means asynchronicity Synchronicity in this means that everything runs in order as you might expect while reading the code. Asynchronicity means that some code can execute right away, some code will be skipped, and some code will be put to the side, only to be run later. If there is something you run into a lot of in JavaScript, it's that a lot of things are asynchronous. You have a lot of things on a web page that are waiting for user input. However, the web site can't freeze itself or force the user to do things in a specific order, because this decreases the quality of the user experience. In a server, when you do a database request, you don't want this hanging the entire server because a database request can take a while. You want the server to go right back to serving other people's requests if the current one is going to take a while and can be put off to the side. In JavaScript, these are handled by mechanisms such as callbacks and Promises. For example, here's some client code I've written, requesting to the server to get a list of groups: var getInfo = function(){ // Making an HTTP GET request $http.get('/groups/getList?index=' + $scope.startIndex) .then( function(response){ if (response.data.status === 30000){ $scope.groupList = $scope.groupList.concat(response.data.groupList); $scope.startIndex += response.data.groupList.length; } else { console.log("There was an error getting groups. Code:" + response.data.status); } }, function(response){ console.log("There was an error getting groups. Code:" + response.data.status); }); // Script resumes from here after making the HTTP GET request console.log("I made a HTTP GET request!"); }; The first part has the client make an HTTP GET request to the server to a particular URL for getting a list of groups. Since the server isn't going to respond instantaneously, the client will put this action off to the side and continue executing. What happens then is the client will execute console.log("I made a HTTP GET request!"); immediately afterwards. Essentially, for the moment since the data isn't available, it skips everything from the HTTP request function to the comment about where the script resumes. When the server sends the data back to the client, a signal is generated to let the client know to go back and execute the code that was skipped. This is a key point in multi-threaded programming. Things need to be asynchronous. The application needs to be able to put tasks that are waiting for something else to be cast to the side and signal the application when the result comes in. People may be sharing resources and you need to manage them An example is on Wikipedia. What if two people are editing a page at the same time, but adding different things to the page? How do you handle them both saving data? This is a common issue with multi-threading programming. One way of handling it the server having a token that only one person can take. If the token was taken, then nobody else can touch the page until the token is released. Another solution is if someone submits their edit, then another does, you can respond "hey, someone made changes already." Web application development gives you more control in the debugging process This part makes understanding how each bit interact with each other easier. One of the hardest things about developing and debugging multi-threaded applications is that a lot of things happen on the OS and processor level. It can be hard to poke into those to figure out what's going on. Like when you want to pause the execution of the application in the source code, you're not quite sure which thread you're on. When you're doing web application development, each instance you are accessing the web page can be thought of as a process or a thread in the entire application. In this way, you can pause one instance's execution and know exactly which one you're poking at. In another sense, you may be able to control aspects behind the scenes, such as latency and such. It's harder to see how a local application will behave with hiccups and such without clunky methods, but you can certainly add latency to your network or simulate it another way without adding debug code or whatnot. It's practical and relatively easy to setup! One of the hardest problems with learning something about software development is what to do with it. I'm finding full stack web development practical to learn because it touches upon something we all use in our daily lives. So instead of trying to figure out a local application you can run that can be multithreaded, try developing a website server and a client to go with it. The flip side is it's very visible and you can see your results. Now I say it's relatively easy to setup, but it still has a learning curve. In my case, at the barest minimum you need to learn HTML and JavaScript. CSS is highly recommended. Then again, multi-threaded programming isn't a beginner level concept either. But if you take an afternoon to study, you can certainly get a web server setup: https://www.tutorialspoint.com/nodejs/nodejs_express_framework.htm My development setup at the moment is: VirtualBox with Lubunutu Node.js with Express as the server framework. MongoDB for the database. This is a document-oriented database, as opposed to a relational database like SQL. Whatever text editor of choice you want (I use Atom).
-
- programming
- web app
-
(and 1 more)
Tagged with: