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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:06:04+00:00 2026-06-08T07:06:04+00:00

I have a simple html file. It access url1 and successfully parse the json

  • 0

I have a simple html file. It access url1 and successfully parse the json response.

CLIENT -> URL1 -> Response to client

I modified my code in html and invoked URL2

CLIENT -> URL2 -> URL1 -> Response to URL2 -> Response to Client

I commented url1 and invoked url2. url2 is a simple servlet which invokes url1 and gets the response. The servlets returns the same response back to the client but this time ajax/jquery returns parse error. When i alert (request.responseText), it exactly matches the response returned by URL1.

$.ajax({   
//url: "http://abc1.com", // Line 1  
  url: "http://abc2.com", // Line 2   
  data: {param1, param2},    
  dataType: "jsonp",            
  type: "GET",  
      async:false,  
    success: function(parsed_json) {  
            alert("Success");           
        },
        error: function (request, status, error) {  
            alert("Error" + error);
            alert(request.responseText);
        }

The Servlet is just a layer in between which copies the content of the input stream to the output stream.


InputStream input = new URL(url).openStream();
resp.setContentType("application/json");
// Apache commons IOUtils to copy
IOUtils.copy(input, resp.getOutputStream());
resp.getOutputStream().flush();

I manually verified the json-string-response and it appears to be the same.
What could be the problem ?

  • 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-06-08T07:06:06+00:00Added an answer on June 8, 2026 at 7:06 am

    Here’s one possible issue: I note that dataType is jsonp, which is different than json. jQuery could conceivably throw an error if the request came back as JSON when it was expecting JSON-P. Does changing the dataType to json change anything?

    Here’s the difference, by the way:

    JSON-P is used primarily for communicating with remote websites. Since browsers can’t send AJAX requests to other domains for security reasons, a JSON-P “AJAX request” will actually add something like this to the DOM:

    <script src="http://www.otherwebsite.com/info.js?callback=myCallback"></script>
    

    If the remote site supports JSON-P, it will return something like this:

    myCallback({"foo": "bar"})
    

    Then your myCallback function is called with the data from the remote site – ta da!

    jQuery handles all this callback business automatically if you say dataType is jsonp, but, if you say jsonp but don’t wrap the data in a callback, (as I understand it) jQuery will notice that the script loaded and throw an error since the callback never fired.

    Or maybe it is JSON-P and I’m just wasting by breath. Anyway. Just in case 🙂

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

Sidebar

Related Questions

I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I want to have a simple HTML file act as a bootstrap for a
can anyone help? I have a simple html file which i am filling via
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a simple ajax query to a file which basically returns in JSON
I have these (sample) lines in a HTML-file: test.ABC.test test.ABCD.test test.ABCE.test And this Ant
I have simple HTML page with svg like this: <div id=plan> <svg xmlns=http://www.w3.org/2000/svg version=1.1>
I have a simple html form. This form has a specific width and margin
I have a simple HTML Form with one column having a select menu with
I have a simple html login form which is validated with javascript before its

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.