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

The Archive Base Latest Questions

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

Just beginner in php, I want to call php method using AJAX. I tried

  • 0

Just beginner in php, I want to call php method using AJAX. I tried every thing but don’t know what error is. Not getting any response from object xmlhttp.

Heres my java script code :

function loadData(){
    var mID=ddItems;
    var method=2;
    var xmlhttp;
    if (window.XMLHttpRequest) {    
        xmlhttp = new XMLHttpRequest();
    }
    if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) {
        xmlhttp.open("GET", "../code/GetItemsInDD.class.php?id=" + mID + "&method=" + method, true); **// is this statement correct**

    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState==4 && xmlhttp.status==200) **//conditin is false,**
        {
            document.getElementById("ddItems").innerHTML=xmlhttp.responseText; 
        }
     }
    xmlhttp.send();
    }
}

My js file is on “projectname/javascript/script.js” and my php file is in “projectname/code/GetItemsInDD.class.php” dir.

  • 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-18T12:33:18+00:00Added an answer on June 18, 2026 at 12:33 pm

    Why don’t you use jQuery for making AJAX requests? Its as simple as this, include jQuery in your page

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    

    and JS code,

    $.ajax({
      type: 'GET',
      url: '../code/GetItemsInDD.class.php?id=" + mID + "&method=" + method',
      success: function (data) {
         document.getElementById("ddItems").innerHTML = data; 
      }
    });
    

    This way, you don’t need to check for the readyState and status thing

    jQuery follows object oriented approach for declaring XMLHttpRequest objects, so you won’t have to worry about creating multiple objects for making more than one AJAX requests.

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

Sidebar

Related Questions

Hi I am a C++ beginner just encountered a problem I don't know how
I am just a beginner here. I am using xampp1.7.1 php version 5.2.9 and
I don't even know how to describe what I want, but here goes. Assume
I am conversant with PHP but I am a beginner with AJAX, and JSON
I'm just a beginner of a PHP coding. I need to know normally industry
I am little more than beginner PHP programmer and just recently started to use
I'm just a beginner at c++ so I might be doing something wrong but
I'm just a beginner with android. I want to divide a bitmap image into
Could someone please help me in here, I'm just a beginner who want to
This may sound like a stupid question but I'm a beginner not just 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.