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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:29:35+00:00 2026-05-11T07:29:35+00:00

JSON allows you to retrieve data in multiple formats from an AJAX call. For

  • 0

JSON allows you to retrieve data in multiple formats from an AJAX call. For example:

$.get(sourceUrl, data, callBack, 'json'); 

could be used to get and parse JSON code from sourceUrl.

JSON is the simply JavaScript code used to describe data. This could be evaled by a JavaScript interpreter to get a data structure back.

It’s generally a bad idea to evaluate code from remote sources. I know the JSON spec doesn’t specifically allow for function declarations, but there’s no reason you couldn’t include one in code and have an unsafe and naive consumer compile/execute the code.

How does jQuery handle the parsing? Does it evaluate this code? What safeguards are in place to stop someone from hacking sourceUrl and distributing malicious code?

  • 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. 2026-05-11T07:29:36+00:00Added an answer on May 11, 2026 at 7:29 am

    The last time I looked (late 2008) the JQuery functions get() getJSON() etc internally eval the JSon string and so are exposed to the same security issue as eval.

    Therefore it is a very good idea to use a parsing function that validates the JSON string to ensure it contains no dodgy non-JSON javascript code, before using eval() in any form.

    You can find such a function at https://github.com/douglascrockford/JSON-js/blob/master/json2.js.

    See JSON and Broswer Security for a good discussion of this area.

    In summary, using JQuery’s JSON functions without parsing the input JSON (using the above linked function or similar) is not 100% safe.

    NB: If this sort of parsing is still missing from getJSON (might have recently been added) it is even more important to understand this risk due to the cross domain capability, from the JQuery reference docs:

    As of jQuery 1.2, you can load JSON data located on another domain if you specify a JSONP callback, which can be done like so: ‘myurl?callback=?’. jQuery automatically replaces the ? with the correct method name to call, calling your specified callback.

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

Sidebar

Related Questions

I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When
I'm designing an application that allows the user to retrieve his data from the
I call a remote data source and get back json. After I select an
I have developed an API restful in JSON to retrieve data from my server
I'm stuck trying to retrieve data from an associated model store. Allow me to
Facebook Graph API allows getting Facebook objects like posts, videos etc in JSON from.
I have a webpage that uses JavaScript to retrieve JSON from a web service.
I have tried to use the following code to retrieve the data from the
rails 3: include_root_in_json = true allows to have a root property for json response.
When working with JSON, I can use NuGet to add JSON.Net and this allows

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.