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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:49:57+00:00 2026-05-23T10:49:57+00:00

hi i have a ajax code for deleting a row from db it has

  • 0

hi i have a ajax code for deleting a row from db

it has a id argument to Identified that row

i want to be able to use that after the deleting is done on the stateChangedd function

function stateChangedd()
{
  if (xmlhttp.readyState==4)
  {
alert('done');
alert(id);

  }
}

but it says id is undefined

here is the complete code

function deletrow(id)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }



alert(id);

url=encodeURI("handler.php?id="+id+"&do=delete");
xmlhttp.onreadystatechange=stateChangedd;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChangedd()
{
  if (xmlhttp.readyState==4)
  {
alert('done');
alert(id);

  }
}

function GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
return objXMLHttp;

} 

i get the first alert which says done! but i cant get the second one

with anonymous function none of the alerts work , it sends the url though

function deletrow(id)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }



alert(id);

url=encodeURI("handler.php?id="+id+"&do=delete");
xmlhttp.onreadystatechange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

xmlhttp.onreadystatechange=function()

{
  if (xmlhttp.readyState==4)
  {
alert('done');
alert(id); 
  }
}

function GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
return objXMLHttp;

} 
  • 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-23T10:49:58+00:00Added an answer on May 23, 2026 at 10:49 am

    That’s because id is not in stateChangedd’s scope. just use the stateChanged function as an anonymous function in onreadystatechange would work:

    function deletrow(id)
    {
    
        xmlhttp=GetXmlHttpObject();
        if (xmlhttp==null)
        {
            alert ("Browser does not support HTTP Request");
            return;
        }    
    
        alert(id);
    
        url=encodeURI("handler.php?id="+id+"&do=delete");
        xmlhttp.onreadystatechange = function(){
            if (xmlhttp.readyState==4){
                alert('done');
                alert(id);
            }
        }
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
    }
    
    
    function GetXmlHttpObject()
    {
        var objXMLHttp=null;
        if (window.XMLHttpRequest)
        {
            objXMLHttp=new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {
            objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        return objXMLHttp;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed code with Ajax and jQuery. I have got a response from
I have some jQuery code. I have called an Ajax function file, file.php, that
I have this code that performs an ajax call and loads the results into
I have some jquery code that is doing an ajax lookup and returning comma
I have Ajax file in which code has written to accept values form user
i have the ajax code that is displayed in some div at the very
I have some ajax code that executes on mouseclick. It calls a file called
I have some simple ajax code. All I want to do is load a
I have the following AJAX and XML code. You can see the values that
I have some PHP AJAX code that is supposed to validate some parameters sent

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.