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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:25:18+00:00 2026-05-15T09:25:18+00:00

I use jquery ajax method, set datatype json, I get a jsonp response from

  • 0

I use jquery ajax method, set datatype json, I get a jsonp response from a cross-domain server. But what i want is raw string of json response. so i set datatype text, but i got nothing but a empty string.

      $.ajax({
        url:"http://api.douban.com/book/subject/isbn/9787802057388?alt=xd&callback=?",
        dataType:'text',
        success:function(data){
            alert(data);
        } //endof success
    }); //endof .ajax

can any one tell me why?
if use getJSON method to do this, how can i get a raw string of json?

  • 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-15T09:25:19+00:00Added an answer on May 15, 2026 at 9:25 am

    Setting the dataType to text prevents jQuery handling the request as a JSONP. jQuery does some magic in the background for these type of requests (substituting callback=? in the URL for a function name, and defining the success function as a global function).

    Why do you want the response to be raw text? It isn’t possible to get a response that is just JSON from a JSONP request, because the nature of JSONP requires the response is wrapped in a function call.

    Setting the dataType to jsonp works, but of course an object is returned.

    $.ajax({
        url:"http://api.douban.com/book/subject/isbn/9787802057388?alt=xd&callback=?",
        dataType:'jsonp',
        success:function(data){
            alert(data);
        } //endof success
    }); //endof .ajax​​​​
    

    If you want a string, you could double-json-encode a part of the response on the server, so that it is received as a string, or use a JavaScript JSON encoder on the client and encode it again, but both don’t really seem ideal solutions. An object is much more usable and useful.

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

Sidebar

Related Questions

I have an ajax call (JSONP) using JQuery with GET method. I think because
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I use jQuery and AJAX to load content from links and forms into a
I use jQuery to do AJAX calls. But specialchars like ÆØÅ (danish letter) comes
We are using jQuery to perform ajax calling. We use different methods - $.get
Every time I use a success function of jQuery.ajax I get the following result
I am using the JQuery .post method to get data using an AJAX call.
When I'm taking my query using Ajax on jQuery, o try use the method
How would I call a PHP Method/function from jQuery ajax. Is this even possible?
Assume we use jQuery.ajax() to POST data with two parameters, game_id and player_id .

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.