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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:44:11+00:00 2026-05-18T00:44:11+00:00

I am working on a project where I have to send an ajax request

  • 0

I am working on a project where I have to send an ajax request to some java based middleware that someone else is in charge of. 4 things can happen in response to the data I POST back…

  1. the userid is correct so the response I receive includes:

    XMLHttpRequest.responseText = “someurl.html”
    XMLHttpRequest.status = 200

  2. the userid is correct but the person does not match a certain status:

    XMLHttpRequest.responseText = “wrongstatusurl.html”
    XMLHttpRequest.status = 200

  3. the userid is correct but the captcha is wrong so the response I receive includes:

    XMLHttpRequest.responseText = “Error. Captcha wrong.”
    XMLHttpRequest.status = 200

  4. the userid is not correct:

    XMLHttpRequest.responseText = “Error. Not a user.”
    XMLHttpRequest.status = 200

So as you can see each response is 200 OK. This means every ajax request hits my “success” callback (I’m using jQuery for this bit and it has a built in success callback as part of its ajax method) so I need to base my callback handling on the actual text I receive back. Correct?

Either that or I need to get the middleware guy to send back status codes that better match the actual status of the request… does that sound right?


My Question:

What is the best way to proceed here? Just handle the plain text that is returned (suggestions on how to best do that would be most appreciated… just parse the text? Seems kind of inflexible… what if the text changes some day?) or get some other sort of response back (suggestions on what to tell him I need most appreciated… just say, I need some kind of header that specifies the status code… maybe?). How would you handle this?

  • 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-18T00:44:12+00:00Added an answer on May 18, 2026 at 12:44 am

    I think the best way would be to parse the responseText and hope that they never get changed.

    If you were in charge of the actual pages/data being returned you’d have more flexibility. The way I would typically have written that end (the end you have no control over) is to return some sort of XML/JSON always. This way if the status was 200, you’d get some data (regardless of an error in the processing, vs page not found or something). Within that data I typically throw a tag (true or false) and an tag with the data for any error message. If there were no error I’d return the rest of the data afterwards.

    I would then use the responseXML and iterate over the nodes, check out my status/error nodes and alert the user to the error (simply by displaying the error node text which would be the message). If there were a success, I would continue processing the remaining nodes depending on how I needed them. It would be a little easier now with JSON and jQuery’s support for it within the ajax methods.

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

Sidebar

Related Questions

I have project that I'm working on that is going to require a webserver.
I'm working on a project where I have 2 web services that need the
On a recent project I have been working on in C#/ASP.NET I have some
I am working a project that does not have a trunk / branches /
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I have a project that I'm working on and I need to be able
I have been working on a project that has 2 interfaces - windows forms
I have a project that I am working on at my job and I
i'm working in a project where i need to read some values and send
What I have so far: I'm currently working on a Lift-based project for work.

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.