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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:40:39+00:00 2026-05-29T12:40:39+00:00

I have a working PHP web service that returns data (if I input the

  • 0

I have a working PHP web service that returns data (if I input the url into the browser I get the results). I need to use Javascript to retrieve this data from my web service, but I’m not too great with Javascript. Based on all the tutorials, examples, and StackOverflow questions and answers I’ve read this should work, but it doesn’t. Please Help!

<script type="text/javascript">

var url = '*working url*';
var xmlhttp = null;
if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
} 
else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
else { document.write('Perhaps your browser does not support xmlhttprequests?'); }

xmlhttp.open('GET', url, true);
xmlhttp.send(null);

xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    var myObj = eval ( xmlhttp.responseText );
  } else {
    // wait for the call to complete
  }
};

</script>

Also, I need help making sure that I’m calling this correctly. Currently I do it like this, which may be the problem:

<script type="text/javascript">
document.write(myObj);
</script>
  • 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-29T12:40:41+00:00Added an answer on May 29, 2026 at 12:40 pm

    I’m aware this doesn’t directly answer your question but if you are “not too great” with javascript I would recommend just going straight to jQuery instead of messing with the lower level objects.

    It will also help you with cross browser compatibility.

    http://jquery.com/
    http://api.jquery.com/category/ajax/

    However if you have a particularly boring day some time in the future, going back and learning what’s going on behind the scenes is always beneficial.

    This would be a simple ajax post using jQuery (with a text response):

    $.post(
        "test.php", 
        { postValue1: "hello",
          postValue2: "world!" },
        function(data){
            alert("Success: " + data);
        }, 
        "text");
    


    To answer your second question (in comments), the code looks correct but perhaps you’re getting a bad response. You can attach additions events onto the ajax call to get additional information.

    This code is borrowed and modified from jQuery’s site:
    http://api.jquery.com/jQuery.post/

    I got the function parameter info from:
    http://api.jquery.com/jQuery.ajax/

    // Assign handlers immediately after making the request,
    // and remember the jqxhr object for this request
    var jqxhr = $.post("example.php", function() {
      alert("success");
    })
    .success(function(data, textStatus, jqXHR) { alert("second success"); })
    .error(function(jqXHR, textStatus, errorThrown) { alert("error"); })
    .complete(function(jqXHR, textStatus) { alert("complete"); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# application that communicates with a PHP-based SOAP web service for
i have created a simple web service using Php Nusoap. its working correctly but
I'm working on a class-based php web app. I have some places where objects
I am a web-developer working in PHP. I have some limited experience with using
I am working with php and want to have a page that has a
I have some issues with a PHP file that is not working properly. The
I'm working profesionally on a php web application which contains contacts, among other data.
I am working on a web service for which we have already developed apps
I have a PHP webservice that returns an XML output, and one of the
I have implemented a web service in PHP. This service takes name/value pairs as

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.