Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:05:02+00:00 2026-05-24T08:05:02+00:00

I am writing code that will use AJAX requests to get some HTML code

  • 0

I am writing code that will use AJAX requests to get some HTML code from the server to embed, but I cannot seem to get the JSON format correct. Can anyone tell me what I am doing wrong?

{"response": 
 [
  {"code": "<div id=\”sponsors\” class=\”infoBox\” > <div class=\”title\”>THANK YOU 2011 SPONSORS!</div> <div class=\”section\”> <div class=\”party\”><a href=\”http://www.ChickRussell.com\”>Chick Russell Communications</a></div> <div class=\”cityState\”>Pasadena, California</div> <div class=\”description\”> Chick Russell Communications is a story-driven creative development company, not a design-driven company. It's one of our main distinguishing features. It doesn't matter how great it looks if it doesn't create the desired effect. <a href=\”/vendors/info/17280\”>more...</a> </div> <div class=\”web\”><a href=\”http://www.ChickRussell.com\”>www.ChickRussell.com</a></div> </div>  </div>"
  }
 ]
}

When I try to run JSON.parse() on it, I get a syntax error

Here is the code I am using to read the JSON:

<script language="JavaScript" type="text/javascript">
var newxhr = new XMLHttpRequest()

newxhr.onreadystatechange = getResponse

function getResponse(){
    if(newxhr.readyState == 4) {
        var response = newxhr.responseText;

        console.log(response)

        response = JSON.parse(response)

        newxhr.close;
    }
}

var url = "http://*.*.net/test.json";

newxhr.open("GET", url, true);
newxhr.send(null)
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:05:03+00:00Added an answer on May 24, 2026 at 8:05 am

    ” and " are different characters. You need stright quotes, not curly ones. (Tell your browser to zoom in if you can’t see the difference … and don’t use an editor (e.g. many word processors) that converts to curly quotes automatically, use a proper text editor (I’m fond of ActiveState Komodo)).


    Old answer (before the JSON in the question was revised):

    The first thing you are probably doing wrong, is trying to build JSON by hand. Use a library instead.

    The second thing you are doing wrong is HTML encoding (badly) your quote marks. To escape a " inside a JSON string you represent it as \".

    The third thing (but it could be just that you are giving a poor example) is bothering to use an array for a single object.

    When I try to run JSON.parse() on it, I get a syntax error

    Despite the problems with it, what you have is valid JSON, so that should not happen. You appear to have reduced your test case so far that the problem you are having doesn’t appear in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some code that will get executed before the DOM loads, basically, using
I am writing some new code that will throw a custom exception - I
I'm writing some documentation that will occasionally include C# or C++ code snippets. In
I am writing a macro for Visual studio that will generate some code. I
I have a dev, that will get around our code coverage by writing tests
I'm writing some pretty CPU-intensive, concurrent numerical code that will process large amounts of
I am writing some code that will prepare my database for my application. In
I'm writing some code that id like to be able to work with any
I'm writing code that looks similar to this: public IEnumerable<T> Unfold<T>(this T seed) {
I find myself writing code that looks like this a lot: set<int> affected_items; while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.