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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:03:16+00:00 2026-06-09T09:03:16+00:00

I have 3 files: f1.php <?php echo ‘dis’; ?> f2.js $.ajax({ url: scripts/f1.php, success:

  • 0

I have 3 files:

f1.php

<?php
 echo 'dis';
?>

f2.js

 $.ajax({
  url: "scripts/f1.php",
  success: function (rsp){

   // if its not exist
   if(rsp == "dis"){
    $("#sbmt_a").attr("disabled", "disabled"); //Disable Button
    //return = true;
   }
    else{
     $("#sbmt_a").removeAttr("disabled");
     // return = false;
    }
  }
 })

p1.php

//include f2.js - this is removed. code from f2.js is added at the bottom just before </body>
<body>
<form>
...
<button id="sbmt_a" name="sbmt_a" class="eee">Submit</button>
</form>

$(document).ready(function(){
     $.ajax({
  url: "scripts/f1.php",
  success: function (rsp){

   // if its not exist
   if(rsp == "dis"){
    $("#sbmt_a").attr("disabled", "disabled"); //Disable Button
    //return = true;
   }
    else{
     $("#sbmt_a").removeAttr("disabled");
     // return = false;
    }
  }
 })
});
</body>

Now if I add in my js file something like form.submit(function(){ I can use the $.ajax code and do whatever I like.

But is there a way to run the $.ajax code when someone visits my page? I mean when my page loads/reloads and the echo in f1.php is “dis” the form button becomes disabled.

  • 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-09T09:03:19+00:00Added an answer on June 9, 2026 at 9:03 am

    You may put in your AJAX call within in the page p1.php

    $(document).ready(function() {
      // Handler for .ready() called.
    });
    

    In most cases, this event triggers as soon as the DOM hierarchy has been fully constructed.

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

Sidebar

Related Questions

I have 2 php files. index.php: <?php $counter = 0; require_once('temp.php'); temp(); echo $counter;
I have the following js files in my code for EditInPlace... <?php echo $javascript->link('jquery.js');?>
I have a PHP file with one simple echo function: echo 'アクセスは撥ねりません。'; but when
I have two files: index.php /lib/user.php Index contains the form: <div class=<? echo $msgclass;
I have the following html to upload files: <?php echo <pre>; var_dump($_FILES); echo <br
I have two files: template.php: <div><?php echo $myVar; ?></div> controller class MyClass extends Base
i have two files trying to use ajax here is code of test.php file
So I have a php file called Time.php: <?php echo (( $DateTime.date(n/j/Y g:i:s A).Hour
I have one line in php file like this: <a class=hide-if-no-js onclick=findPosts.open( 'media[]','<?php echo
Suppose I have a example.php file like that: <p> <?php echo _('Hello world') ?>

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.