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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:17:07+00:00 2026-06-18T18:17:07+00:00

I am trying to use jQuery’s ajax to call a php script onload. This

  • 0

I am trying to use jQuery’s ajax to call a php script onload. This script will return xml from a url web service, parse through it, and then display bits and pieces of it into a div tag when the page loads (onload). I’m okay with php when it comes to using forms, but getting php scripts to run onload is not working for me. Could someone please look through my code and give me your advice? Thanks in advance.

HTML:

<!doctype html>
<html>
  <head>

    <title>Word of the Day</title>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="code.js"></script>

  </head>
<body>

<h3>Word of the Day: </h3>
<div id="word_day"></div>

</body>
</html>

JavaScript:

$(document).ready(function() {

  $(window).load(function() {


    $.ajax({
      post: "GET",
      url: "word_day.php"
    }).done(function() {
      alert(this.responseText);
    }).fail(function() {
      alert(this.responseText);
    });


  });

});

I did not add my PHP code since I was pretty sure that it wasn’t the cause of my frustration.

  • 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-18T18:17:09+00:00Added an answer on June 18, 2026 at 6:17 pm

    You don’t need those two handlers, just one:

    $(document).ready(function() 
    {
        $.ajax(
        {
            post: "GET",
            url: "word_day.php"
        }).done(function() 
        {
            alert(this.responseText);
        }).fail(function() 
        {
            alert(this.responseText);
        });
    
    });
    

    As you had it you were trying to create one handler when the handler fired which was never going to work.

    Edit:

    Your done/fail part should look like:

    }).done(function(data) 
    {
        alert(data);
    }).fail(function(jqXHR, textStatus, errorThrown) 
    {
        alert(textStatus);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use jquery ajax to get data from a php file.
I am trying to use jQuery's ajax functionality to update data from a web
I am trying to use JQuery to parse a sitemap.xml to look like this
I am need paint my image. I'm trying use JQuery in here this link:
I am trying to use jQuery ajax to send a json object to a
im trying to use jquery bbq for remembering page with ajax. but i wonder,
I am trying to use jQuery with multiple selections from http://jqueryui.com/autocomplete/#multiple-remote The js works
I am trying to use jquery's ajax $.get(...) function to send a request to
I am trying to use jQuery with Rails and AJAX to accept a post
I am trying to use jQuery to move a form from one div to

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.