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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:40:49+00:00 2026-06-15T19:40:49+00:00

I have a web service from which I receive XML response. In jQuery I

  • 0

I have a web service from which I receive XML response. In jQuery I have the following, for getting a certain book:

function getBookByIsbn() {

if($("#getAndDeleteIsbn").val() == '')
{
    alert("Please provide the ISBN");
    return false;
}
$.ajax({
    dataType: 'xml',
    type: 'GET',
    url: 'http://localhost:8080/library/books/' + $("#getAndDeleteIsbn").val(),
    success: function (data) {
        var string;
        if (window.ActiveXObject){
            string = data.xml;
        }
        else
        {
            string = (new XMLSerializer()).serializeToString(data);
        }
            $("#messageBox").text(string);
    },
    error: function (xhr, status, thrownError) {
        var string;
        if (window.ActiveXObject){
            string = thrownError.xml;
        }
        else
        {
            string = (new XMLSerializer()).serializeToString(thrownError);

        }
            $("#messageBox").text(string);
  }
});
}

Now, when the request is successful, the message is displayed, but when I receive an error, the content will not be displayed. What am I doing wrong?

EDIT: Someone adviced me to print all the three parameters in the console, so I’ve found out that actually the xhr parameter contains what I need. The problem now is that if I try to create an alert(xhr.responseText), the alert window contains the desired message, but if I want to display the same thing inside the div, nothing happens, and I want it to be displayed there.

  • 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-15T19:40:50+00:00Added an answer on June 15, 2026 at 7:40 pm

    The problem was that I tryed to serialize a string to string, because xhr.responseText is a string. To solve the problem, instead of xhr.responseText, it should be xhr.responseXML.
    Here is the code:

    function getBookByIsbn() {
    
    
    if($("#getAndDeleteIsbn").val() == '')
    {
        alert("Please provide the ISBN");
        return false;
    }
    $.ajax({
        dataType: 'xml',
        type: 'GET',
        url: 'http://localhost:8080/library/books/' + $("#getAndDeleteIsbn").val(),
        success: function (data) {
            var string;
            if (window.ActiveXObject){
                string = data.xml;
            }
            else
            {
                string = (new XMLSerializer()).serializeToString(data);
            }
                $("#messageBox").text(string);
        },
        error: function (xhr, status, thrownError) {
            var string;
            if (window.ActiveXObject){
                string = xhr.responseXML.xml;
            }
            else
            {
                string = (new XMLSerializer()).serializeToString(xhr.responseXML);
    
            }
                $("#messageBox").text(string);
      }
    });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have is an XML we receive from a web service which represents
I have the following JSON coming back from a web service which I am
I have a web service from which i receive data, put it in a
I have a WCF web service which is responsible for managing work sent from
I have a ReSTful web service which needs to parse locale-sensitive data from the
I have a WCF Web Service which is referenced from a class library. After
I have a web service with just 1 Web method which will accept xml
I've managed to parse xml responses from a SOAP web service when I receive
I have a web service which receive a string. This string contains multiple keys
I have a .NET webservice which I need to hit asynchronously from the jQuery

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.