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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:37:23+00:00 2026-05-23T04:37:23+00:00

I’m looking for a way to return a single JSON/JSONP string from a cross-domain

  • 0

I’m looking for a way to return a single JSON/JSONP string from a cross-domain “AJAX” request. Rather than request the string and have JQuery return it as a generic object automatically, I want to get a hold of the string BEFORE that conversion happens. The goal here is to parse it myself so I can turn it straight into new objects of a certain type (e.g. a Person object).

So, just to make this clear, I don’t want any string-to-generic-object conversion going on behind the scenes and this must work using a different domain.

Here’s a non-working example of what I would like to do:

$.ajax({
    type: 'GET',
    url: 'http://www.someOtherDomain.com/GetPerson',
    dataType: 'text',
    success: parseToPerson
});

function parseToPerson( textToParse ) {
    // I think I can do this part, I just want to get it working up to this point
}

I’m perfectly happy if JQuery isn’t involved in the solution, as long as it works. I would prefer to use JQuery, though. From what I’ve read, the javascript techniques used to get JSONP data (dynamically creating a script element) would probably work, but I can’t seem to get that to work for me. I control the domain that I am requesting data from and I can get the data if I change the dataType in the AJAX call to ‘JSONP’, so I know that is working.

  • 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-23T04:37:23+00:00Added an answer on May 23, 2026 at 4:37 am

    If your data is being retrieved from another domain, you will need to use JSONP (there are other options, but JSONP is by far the easiest if you control the service). The jQuery call will look like this:

    $.ajax({
        // type: 'GET', --> this is the default, you don't need this line
        url: 'http://www.someOtherDomain.com/GetPerson',
        dataType: 'jsonp',
        success: parseToPerson
    });
    

    The actual request that goes to your service will be http://www.someOtherDomain.com/GetPerson?callback=arbitrary_function_name. On the service side, you will need to return data like this:

    arbitrary_function_name("the string (or JSON data) that I want to return");
    

    So you’ll need to inspect the querystring parameters, get the value of the callback parameter, and echo it out as if you’re calling a Javascript function with that name (which you are), passing in the value you want to provide through the service. Your success function will then get called with the data your service provided.

    If you’re deserializing the returned data into a Javascript object, you might be better off returning JSON data than a string, so the data your service returns might look like this:

    arbitrary_function_name({
        "name":"Bob Person", 
        "age":27, 
        "etc":"More data"
    });
    

    That way you don’t have to worry about parsing the string – it’ll already be in a Javascript object that’s easy to use to initialize your object.

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

Sidebar

Related Questions

No related questions found

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.