Q1 What is the MIME type for JSON A1 applicationjson Q2 Consider the following

Q1 what is the mime type for json a1 applicationjson

This preview shows page 6 - 9 out of 9 pages.

Q1: What is the MIME type for JSON? A1: application/jsonQ2: Consider the following script: <script type="text/javascript"> eval("x=10;y=20;document.write(x*y)"); document.write("<br />"); document.write(eval("2+2")); document.write("<br />"); var x=10; document.write(eval(x+17)); document.write("<br />"); </script> What is the output that gets produced? A2:
Image of page 6
7 200 4 27 Q3: What is a JSON “object”? A3: A collection of key:value pairs, comma-separated and enclosed in curly brackets Q4: When should you use arrays when modeling your data? A4: When key names are sequential integers. Q5: What is the following code? // Constructor -- pass a REST request URL to the constructor function JSONscriptRequest(fullUrl) { // REST request path this.fullUrl = fullUrl; // Keep IE from caching requests this.noCacheIE = '&noCacheIE=' + (new Date()).getTime(); // Get the DOM location to put the script tag this.headLoc = document.getElementsByTagName("head").item(0); // Generate a unique script tag id this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++; } // Static script ID counter JSONscriptRequest.scriptCounter = 1; // buildScriptTag method JSONscriptRequest.prototype.buildScriptTag = function () { // Create the script tag this.scriptObj = document.createElement("script"); // Add script object attributes this.scriptObj.setAttribute("type", "text/javascript"); this.scriptObj.setAttribute("charset", "utf-8"); this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE); this.scriptObj.setAttribute("id", this.scriptId); } // removeScriptTag method JSONscriptRequest.prototype.removeScriptTag = function () { // Destroy the script tag this.headLoc.removeChild(this.scriptObj); } // addScriptTag method JSONscriptRequest.prototype.addScriptTag = function () { // Create the script tag this.headLoc.appendChild(this.scriptObj); }
Image of page 7
8 A5: Source code for the Dynamic Script Tag “Hack.” AJAX Questions [10 pts] All questions are worth 2 points Q1: Of the URLs below, which have the same origin? a. b. c. d. e. A1: a and e –OR- “none” Q2: Which of the following are common characteristics of AJAX applications?
Image of page 8
Image of page 9

You've reached the end of your free preview.

Want to read all 9 pages?

  • Fall '07
  • Papa
  • JSON

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture