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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:21:00+00:00 2026-05-23T07:21:00+00:00

I have a javascript which receives info from a servlet using jQuery: $.get(authenticate, {badge:$(‘input#badge’).val()},

  • 0

I have a javascript which receives info from a servlet using jQuery:

$.get("authenticate", {badge:$('input#badge').val()}, function(data) {
        console.log("xml: "+data);   
        displayInfoReturn(data);
    });

When I process the result in Safari, everything works great:

    function displayInfoReturn(data) {
        if (/load/.test(data)) { // ...process string 
        }
    }

But the ‘if’ always returns false in firefox (haven’t tried it yet in IE or Chrome). I also tried using indexOf != -1 and search != -1. Nothing works!

One curious thing I noticed however is when I print data to console:

console.log ("received... "+data);

it comes back with “received… [object XMLDocument]”. So apparently it’s not treating my data as a string. I tried data.toString() but that doesn’t work either. So how can I get firefox to play fair here?

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

    What does your servlet return? An application/xml document or just text/plain? What have you set in response.setContentType()? You seem to be expecting XML and Firefox seems to be telling that it’s really an XML document, but yet you’re treating it as text/plain with that regex .test(). I’m not sure about Safari, but it look like that it has overridden a toString() on the XML document object so that it returns the whole XML string so that your regex by coincidence works fine.

    Without knowing the exact XML document it’s hard to tell how exactly to fix it. If it’s for example

    <data>
        <action>load</action>
    </data>
    

    Then you can check the presence of load value in the <action> tag using jQuery’s own XML parsing facilities as follows:

    function displayInfoReturn(data) {
        if ($(data).find('action').text() == 'load') {
            // ...
        }
    }
    

    See also:

    • Easy XML consumption with jQuery
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JavaScript code which copies the value of input file and paste it
I have a Javascript API, which should be usable with GWT and Flex. Using
My question is about Javascript. I have a Callback function which receives a Position
I have a page in which I use javascript heavily, I use jquery, extjs,
I have a javascript which I didn't write but I need to use it
I have some javascript which catches changes to a form then calls the form's
I have a JavaScript widget which provides standard extension points. One of them is
I have a javascript page which checks an email and username, this works fine
I have a large javascript which I didn't write but I need to use
I have a JavaScript widget which communicates with my Rails app by creating tags

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.