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

  • Home
  • SEARCH
  • 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 155549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:10:31+00:00 2026-05-11T10:10:31+00:00

I have the following javascript functions, which when in a standalone file, will be

  • 0

I have the following javascript functions, which when in a standalone file, will be called correctly from a page.

function deleteItem(layer, url) {     var xmlHttp=GetXmlHttpObject();     if(xmlHttp==null) {         alert('Your browser is not supported?');     }     xmlHttp.onreadystatechange = function() {         if(xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {             if(xmlHttp.responseText == 'result=true') {                 var row = document.getElementById(layer);                 row.parentNode.removeChild(row);             }             document.getElementById(layer).innerHTML=xmlHttp.responseText;         } else if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading') {             document.getElementById(layer).innerHTML='loading';         }     }     xmlHttp.open('GET',url,true);     xmlHttp.send(null); } function deleteRec(layer, pk) {     url = 'get_records.php?cmd=deleterec&pk='+pk+'&sid='+Math.random();     if (confirm('Confirm Delete?')) {         deleteItem(layer, url);     } } function GetXmlHttpObject() {     var xmlHttp=null;     try {         xmlHttp=new XMLHttpRequest();     }     catch (e) {         try {             xmlHttp =new ActiveXObject('Microsoft.XMLHTTP');         }         catch (e) {         }     }     return xmlHttp; } 

It is called like so:

 echo '<td><a href='#' onclick='deleteRec(\'article_' . $pk .'\', \'' . $pk . '\')'>DELETE</a></td>' . '\n';  

This displays the confirm dialog, and will delete the page if OK is clicked, as it should.

However.

When my other necessary functions are placed in the js file, nothing will happen.

function update(layer, url) {     var xmlHttp=GetXmlHttpObject();     if(xmlHttp==null) {         alert('Your browser is not supported?');     }     xmlHttp.onreadystatechange = function() {         if(xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {             document.getElementById(layer).innerHTML=xmlHttp.responseText;         } else if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading') {             document.getElementById(layer).innerHTML='loading';         }     }     xmlHttp.open('GET',url,true);     xmlHttp.send(null); } function updateByPk(layer, pk) {     url = 'get_auction.php?cmd=GetAuctionData&pk='+pk+'&sid='+Math.random();     update(layer, url); } function updateByQuery(layer, query) {     url = 'get_records.php?cmd=GetRecordSet&query='+query+'&sid='+Math.random();     update(layer, url); } function updateByPage(layer, query, pg) {     url = 'get_records.php?cmd=GetRecordSet&query='+query+'&pg='+pg+'&sid='+Math.random();     update(layer, url); } function deleteItem(layer, url) {     var xmlHttp=GetXmlHttpObject();     if(xmlHttp==null) {         alert('Your browser is not supported?');     }     xmlHttp.onreadystatechange = function() {         if(xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {             if(xmlHttp.responseText == 'result=true') {                 var row = document.getElementById(layer);                 row.parentNode.removeChild(row);             }             document.getElementById(layer).innerHTML=xmlHttp.responseText;         } else if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading') {             document.getElementById(layer).innerHTML='loading';         }     }     xmlHttp.open('GET',url,true);     xmlHttp.send(null); } function deleteRec(layer, pk) {     url = 'get_records.php?cmd=deleterec&pk='+pk+'&sid='+Math.random();     if (confirm('Confirm Delete?')) {         deleteItem(layer, url);     } } function GetXmlHttpObject() {     var xmlHttp=null;     try {         xmlHttp=new XMLHttpRequest();     }     catch (e) {         try {             xmlHttp =new ActiveXObject('Microsoft.XMLHTTP');          }         catch (e) {         }     }     return xmlHttp; } function makewindows(html) {     child1 = window.open ('about:blank');     child1.document.write(html);     child1.document.close(); } 

There does not seem to be anything wrong with the JavaScript itself, so I am wondering if something is being canceled out somehow. Even when changing deleterec() to a simple alert nothing happens.

  • 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. 2026-05-11T10:10:31+00:00Added an answer on May 11, 2026 at 10:10 am

    First, in this text block:

            if(xmlHttp.responseText == 'result=true') {                 // Here you remove the appropriate element from the DOM rather than trying to update something within the DOM                 var row = document.getElementById(layer);                 row.parentNode.removeChild(row);         }         document.getElementById(layer).innerHTML=xmlHttp.responseText; 

    You don’t actually want this line:

    document.getElementById(layer).innerHTML=xmlHttp.responseText; 

    Additionally, try placing the deleteRec function first before the deleteItem function in the list of functions.

    I would also recommend that you test this in Firefox with Firebug installed. This will show you any Javascript errors that are occurring on the page.

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

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look at this link: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.objectforscripting.aspx I've actually used… May 11, 2026 at 9:04 pm
  • Editorial Team
    Editorial Team added an answer No, they won't directly affect your app. Keep in mind… May 11, 2026 at 9:04 pm
  • Editorial Team
    Editorial Team added an answer We use normal JUnit for both unit tests and integration… May 11, 2026 at 9:04 pm

Related Questions

How can I emulate classes (and namespaces) in JavaScript? I need to create a
I'm trying to use jQuery.post() function to retrieve some data. But i get no
So I've been working on this all day and I can't figure out how
I have the following javascript: <script type=text/javascript> function showjQueryDialog() { $(#dialog).dialog(open); } $(document).ready(function() {

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.