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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:45:03+00:00 2026-06-14T20:45:03+00:00

I am new in Java and JavaScript and I was looking for a way

  • 0

I am new in Java and JavaScript and I was looking for a way to take an HTTPResponse, parse the .responseText using the .indexOf method so as to take the property I need and after that display this value in a cell of a table row I have created in an html page. Is there a way to replace this cell every time I get the httpresponse?

Thanks a lot.

var xHRObject = new XMLHttpRequest();
var url = "http://meteovarkiza.gr/";
xHRObject.open("GET", url, true);
xHRObject.send();
xHRObject.onreadystatechange = function () {
if (xHRObject.readyState==4 && xHRObject.status==200) {
    var response = xHRObject.responseText;
    var startIndex = response.indexOf("Temperature");
    startIndex += 70;
    var subResponse = response.slice(startIndex, startIndex + 4);                
            alert(subResponse);
    }
}
  • 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-14T20:45:04+00:00Added an answer on June 14, 2026 at 8:45 pm

    “I have tried creating an object that takes this value but after that, I can’t display it in the html table.”

    Your question isn’t very clear, but you seem to be saying that you are successfully getting the particular value you need out of the response text and into the subResponse variable, but you don’t know how to put that value into a particular element on your page.

    If so, the simplest way is to give that element an id:

    <td id="resultCell"></td>
    

    And then do this in your JS:

    document.getElementById("resultCell").innerHTML = subResponse;
    

    In your question title you said:

    “How to parse http response as a string?”

    …but you seem to have figured that out. If you have no control over the response format then I guess a combination of regex tricks and/or .indexOf() and .slice() (or .substr() might be better since in your case you always specify 4 characters) is the way to do it.

    If you can set the format of the response you are probably much better off returning a JSON string, because then you can use JSON.parse() to get an object with directly accessible properties – no more messing around with string manipulation.

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

Sidebar

Related Questions

Im new to both ruby and rails, but have experience with java, javascript and
I am new in share point. I want to select data using java script
We are starting a new Java EE project and am looking for suggestions regarding
Eclipse and MyEclipse create new Java files with an extra blank line after the
I'm new to GWT and also fairly new to doing Java web development, using
i am new to java script and i need some help with following code
I am looking to pass a string from my Java to a javascript showContent
greetings, I'm new with java script so bear with me! I want to achieve
When I start a new Java project in eclipse, the first popup screen allow
When creating a new Java project in IntelliJ IDEA, the following directories and files

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.