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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:35:08+00:00 2026-06-03T02:35:08+00:00

i have a common js file after I reload html page in ajax request

  • 0

i have a common js file
after I reload html page in ajax request , I cant access the functions in this file , the common JS functions between $(document).ready(function()
How can Access them and fire the functions in common file
Example :

COMMON JS :

  $(document).ready(function() { 

 $(".agree_btn").click(function(){
        alert(123);             
    });

});

the Function in the phtml page

$('.loadMoreAnswers').live('click', function(event) {

          var location_id = $(this).attr('location_id');
          var counter= $(this).attr('counter');
                $('#loadingAnswer').show();

        $.ajax({
            type: 'POST',
            url: '/daleel/loadmore',
            data: 'location_id='+location_id+'&part='+'answers'+'&answerCounter='+counter,  //with the page number as a parameter
            success: function(msg){

                if(msg.length!=0)    //if no errors
                { $(this).parent().load("view")
                    $('#loadingAnswer').remove();
                    counter+=5;
                    $('#profile-page-answer').append(msg); 

                } 
                else $("#loadingAnswer").remove();

            },
            dataType: 'html'
        });

              });

its render the HTML like This :

<a agreed="no" agreed-content-id="63066" class="agree_btn" id="agree-a63066">
Agree
    </a>

But when i click on this Link
it doesnt run the function in the Common JS file

  • 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-03T02:35:11+00:00Added an answer on June 3, 2026 at 2:35 am

    rebind the click event handler in the ajax success

    success: function(msg){
     //your code
     $(".agree_btn").bind('click');
    }
    

    or you can use delegate for jQuery versions lower than 1.7 like

    $(document).delegate(".agree_btn",'click',function(e){
     //your code
    });
    

    or of you are using jQuery version 1.7+ use on method

    $(document).on("click",".agree_btn",function(e){
     //your code
    });
    

    do not use .live its deprecated docs

    As of jQuery 1.7, the .live() method is deprecated. Use .on() to
    attach event handlers. Users of older versions of jQuery should use
    .delegate() in preference to .live().

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

Sidebar

Related Questions

I have a header file, lets say Common.h, that is included in all of
I have the following in a java file (MyRtmpClient.java): import org.apache.mina.common.ByteBuffer; and ByteBuffer is
I have common functionality that I need to access from all screens of my
After reading some posts like this one: Choose File Dialog It appears that Android
I have a button on my page that does an Ajax callback with an
I have this C++ file: #include <iostream> int main(int argc, char *argv[]) { std::cout
We're trying to have a master document (after an automated mailmerge) be sent, in
This has to be a common question that all programmers have from time to
This seemed like a common question but after doing some searching, I wasn't really
I have this code to get the caller of my function's file name, line

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.