Sunday 15 September 2013

javascript - Unexpected end of input in JS -


I am trying to load a JSON file via javascript. I have a place button in the HTML that executes the function loadAJAX . But I'm getting an error on line 11 var items = JSON.parse (request.responseText); It says that unexpected end of input I checked many times and found no solution on this.

script.js

  function loaded xx () {var request; If (window.XMLHttpRequest) {request = new XMLHttpRequest (); } Else {request = new ActiveXObject ("Microsoft.XMLHTTP"); } Request.open ("GET", "data.json"); Request.onreadystatechange = function () {if ((request.status === 200) & amp; (request.readyState === 4)) {var items = JSON.parse (request.responseText); Var output = "& lt; ul & gt;"; (For var of objects) {output = = "
  • + Item [Key] .colorName + "& lt; / li & gt;"; } Output + = "& lt; / ul & gt;"; Document.getElementById ("Update"). InnerHTML = Output; }}; Sent request (); } "ColorName": "red", "hexvalue": "# f00", "info": "my favorite color."}, {"ColorName": "green", "hexValue" : "# 0f0", "info": "Older colors for old things, like food Eve." }, {"ColorName": "blue", "hexview": "# 00f", "info": "Reminds me of the injured hand." }, {"ColorName": "cyan", "hexvalue": "# 0ff", "info": "It does not know what color it is." }, {"ColorName": "Magenta", "HexValuue": "#FFF", "Information": "Every girl talks about her color." }, {"ColorName": "yellow", "hexValue": "# ff0", "" info ":" My mother likes. "}, {" ColorName ":" black "," hexValue ":" # 000 "," info ":" OK, now this color looks white white. "}}

    " Information: Older things for old things, like Food eve ".

    You have accidentally quoted the whole line here. The name and value of an object should be quoted separately from the property.

    Rewrite as "info": "Older colors for old things, like food eve".

    Also mask duplicate quote character further down:

    "" info: "My mother likes."

    The key name must have only one info .

  • No comments:

    Post a Comment