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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:21:41+00:00 2026-06-03T03:21:41+00:00

I have searched for the answer to this and the reason I’m not finding

  • 0

I have searched for the answer to this and the reason I’m not finding it could just be that I’m completely botching my script from the getgo, so please anyone who can help I greatly appreciate it.

I have a javascript function which fires onClick of a form submit and runs an ajax call to script1.php, then starts a timer with setInterval. setInterval is calling another javascript function to poll an output file from script1.php so we can get new data added to the screen. This part works fine.

However, I’d like to stop the timer when script1.php is done processing. How do I do this? I’ve tried putting in a clearInterval(myTimer) in script1.php as the last statement it runs, and it seems to be showing up in the browser, but it’s not stopping the timer.

<script type="text/javascript">

var myTimer;
var file1 = "script1.php";
var file2 = "script2.php";


function startTimer(myTimer) {
  myTimer = window.setInterval(loadData, 2000);
}

function stopTimer() {
  clearInterval(myTimer);
}

function startData()
{
ajaxRequest(file1,data);
startTimer(myTimer);

}


function loadData()
{
ajaxRequest(file2)
}


</script>


<form action="index.php" method="post">
<div style="text-align:left;width:300px;">
<textarea style="width:300px;height:200px;"> </textarea><BR>
<button type="button" onclick="startData()">get data</button>
</div>
</form>

<div id="myDiv" style="text-align:left;width:500px;border:solid 1px #ccc;padding:50px;">
please enter data above
</div>
  • 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-03T03:21:43+00:00Added an answer on June 3, 2026 at 3:21 am

    Yes, you botched it. You should just have PHP return the data directly to the script that does the AJAX call.

    On AJAX success, any text outputted by the PHP script will be available to the success callback.

    If you were using JQuery, it would be as simple as:

    $.ajax({
       url: 'someurl',
       success: function(response) {
          // do whatever with response
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched for this answer and have not found it. I have music
Windows Forms, VB. I have searched the web for the correct answer to this
I have searched the internet for an answer to what could be causing EXCEPTION_ACCESS_VIOLATION
I have searched but have not found my answer. Disclaimer: I am brand new
Ok, so I have searched in many places for the answer to this question,
I've searched for this, but couldn't find an answer and for whatever reason I
I have searched and Googled for the answer to this question to no avail.
I have searched for an answer to this, and it is probably a beginner
I have searched S.O. for this answer and have came close to an answer
I wish I would find an answer for this. I have searched and searched

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.