Spring 2017 – Week 9 Class Notes

We are getting close to the end! Unfortunately, I don’t think we are going to get through everything I had hoped, but I think that we will make a solid finish to the year.

Computer Programming

This week we talked a little bit about how websites talk to servers. The most common file format used for communication on the Internet is called JSON, and it is more-or-less just a JavaScript object like you would write in a program. There are a few extra rules that make it easier for other programs to read and write, but it should definitely be recognizable.

However, remember that, for a computer, it doesn’t know what type of data it has until you tell it. Remember, if someone types a number into an input box, it is just treated as a string until you tell it to parseInt or parseFloat. Similarly with JSON. To convert a JavaScript object to a JSON string, using JSON.stringify(myobject). To convert a JSON string to a JavaScript object use JSON.parse(mystring).

You can test this out in your browser console. Just open up the JavaScript console and type the following:

var myitem, mystring, myobj;
myitem = {name: "Product", price: 10};
mystring = JSON.stringify(myitem);
myobj = JSON.parse(mystring);

We also talked about how pages communicate with servers using form tags and input tags. The form tag has an “action” attribute which tells the pag the server URL to talk to. The “method” attribute is either “GET” (for retrieval of information) or “POST” for sending data to the server. The input fields each have a name to identify to the server what field it is. For text fields, the value of the field is what the user types in. Hidden fields can be used for the page to send its own data using the “value” attribute.

YOUR ASSIGNMENTS: (1) If you did not get last week’s cart assignment working, SEND IT TO ME SO I CAN CHECK IT. (2) This week’s cart assignment is to have the “add” button actually add the item to an array. You don’t have to do anything with it yet, just be sure it gets added to some sort of global cart array. (3) Go to the following URL in your browser: https://www.eventelf.com/events/482 Hit the “continue” button to see the activities for this event. Now go look at the JSON feed describing the event: https://www.eventelf.com/events/482.json Copy and paste this to your editor, and reformat it so that you can better read it. See how much of it you can understand. Look back at the page and see which pieces of data are being used on the page. (4) Read PayPal’s documentataion on how to create a form that allows people to ask for money. The documentation is here. See how much of it you understand. (5) Look at the form listed under the heading “Sample HTML Code for Filling Out FORMs Automatically for Buyers”. It doesn’t actually work if you type it in because of some issues with PayPal and non-website-based pages, but this is basically how PayPal buttons are created.


This week we finished our Capacitor series and will move on to inductors. There will be a quiz next week. I will cover RC time circuits and period/frequency, but nothing that is quite as intensive as last week’s homework. The chapter on inductors should be ready this weekend. Right now there is a start of a chapter, but it is not even well-written.


This week we covered how to do trig substitutions. I will try to get a chapter up this weekend, but at least I will post problems.

Leave a Reply

Your email address will not be published. Required fields are marked *