Thursday, 17 September 2015

Time to Catch Up

Last time I saw this blog I was quietly confident about all the progress that I was going to make on this project. Completing the API calls getting the PHP system set up (Learning PHP). However, fast forward a week and I am still in pretty much the same position. Only this time there is a demonstration due in a week. What happened?

Collectively the group decided last week that with a number of other more pressing assessment pieces (I'm looking at you Digital Prototyping) and the demonstration deadline far enough away off we could take a breather and step back from our studio project for the week.

Step forward into this week and I was still hitting a brick wall on the Trove API call. All the other APIs had been configured correctly, or enough to know that they were sending and receiving data (without necessarily manipulating it). The never ending pain came in the form of a console error with the very uninformative, no 'Access-Control-Allow-Origin' header is present.

The Error that plagued my Existence
So after truckloads of reading on StackOverflow as well as the W3Schools I was no closer to an answer. I even found a blog from a student previous taking this course who had the same issue without a real solution. Then after reading the MDNs page on CORS and cross site access restrictions and a few subsequent links I came across JSONP. By using a JSON object with added padding. It essential tricks the server and gets around the Same Origin Policy by wrapping the response up as a script. Scripts thankfully are not subject to this same policy. This website helped to spell it all out for me.

The only problem now was that I had up until this point been writing only in vanilla JavaScript and had not really familiarized myself with the JQuery notation (Sorry DECO7140 two notations and Python syntax at the same time was not going to happen). So of course it was time to hit up the academy


Thanks Code Academy

In a round about kind of way its good that this is making me learn JQuery, because it is definitely a useful library and a skill that I will need to have in the real world. Its just a shame it took hours and hours and hours to realize that it was a necessity for this project.

No comments:

Post a Comment