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 6231719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:59:05+00:00 2026-05-24T09:59:05+00:00

IN my web service,I return one json object in the method: {name:’xx’} I use

  • 0

IN my web service,I return one json object in the method:

{name:'xx'}

I use the ajax to send the request,then parse them using the ‘eval’

onComplete:function(req){
  var data=eval(req.responseText);
  //do something according data
}

However,I can not get the ‘data’.

When I retrun the following string:

[{name:'xx'}]

It worked,and I get the ‘data’ as an array.

Through google,I know that it is caused by the ‘{‘ in the return string.

So I wonder if there is no way to retrun a json object ?

  • 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-24T09:59:05+00:00Added an answer on May 24, 2026 at 9:59 am

    Have a read of this blog post on JSON hijacking. The author explains the issue your running into

    You might have seen code like the following when related to JSON:

    eval('('+JSON_DATA+')');

    Notice the beginning and ending parenthesis, this is to force
    JavaScript to execute the data as an object not a block statement
    mentioned above. If JavaScript did attempt to execute JSON data
    without the parenthesis and the JSON data did in fact begin with “{”
    then a syntax error would occur because the block statement would be
    invalid.

    …more info on why…

    Rather than adding () around your JSON response, you should be using JSON.parse or $.parseJSON like gion_13 has said. Eval isn’t the way to go.

    Also, like quentin said in the comments, you need to change the JSON you’re returning as it’s invalid. You need to quote your key as well as your value.

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

Sidebar

Related Questions

I have a Web Service with Just one Web Method that returns a boolean
Is there an easy way to return data to web service clients in JSON
i'm trying to return a custome object from a web service object returned only
I have a Web Service and it always brings back one object from my
Background: I'm invoking a web service method which returns a JSON string. This string
I'm invoking one of SharePoint's web service APIs that returns a CAML fragment. I've
A web service return to my flex3 client this custom exception: <SOAP-ENV:Fault xmlns:ro=urn:Gov2gLibrary xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
I am calling a web service to return XML data for states/provinces of countries.
I'm writing a web service, and I want to return the data as XHTML.
I have a JAX-RPC (Java) web service that needs to return a complex polymorphic

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.