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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:03:13+00:00 2026-05-15T05:03:13+00:00

I have a link that calls the ajax to load content, and after the

  • 0

I have a link that calls the ajax to load content, and after the content is loaded, my jquery function doesn’t work anymore

Here is my HTML

 <a href="#" onclick="javascript:makeRequest('content.html','');">Load Content</a>
    <span id="result">
 <table id="myTable" valign="top" class="tablesorter">
        <thead>
          <tr>
            <th>Title 1</th>
            <th>Level 1</th>
            <th>Topics</th>
            <th>Resources</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Example title 1</td>
            <td>Example level 1</td>
          </tr>
          <tr>
            <td>Example title 2</td>
            <td>Example level 2</td>
          </tr>
        </tbody>
      </table>
</span>

The table is sorted using jquery table sorter plugin from http://tablesorter.com/docs/
After the ajax content is loaded, another set of table with different data will be displayed. However, the sorting doesn’t work anymore.

Here is my ajax script which is use to load the content :

  var http_request = false;
   function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
     // alert(http_request.status);
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('result').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }

Any idea how I can get the jquery plugins to work after the content is loaded?
I have searched and changed the jquery.tablesorter.js click function into live() like this $headers.live("click",function(e) but it doesn’t work as well.

How can I make the jquery functions to work after the content is loaded?
Thank you


Update script for testing :

<a href="#" id="test" onClick="contentDisp()">Load Content</a>
<div id="result"></div>

<script type="text/javascript"> 
function contentDisp()
{
$.ajax({
url : "test.html",
success : function (data) {
$("#result").html(data);
$("#myTable").tablesorter();
$("#myTable").trigger("update"); 
}
});
}
</script> 

This my test.html. The table sorting works if I don’t put it in loaded content. Once it’s being loaded to div, the sorting doesn’t work anymore.

<table id="myTable" valign="top" class="tablesorter">

    <thead>
      <tr>
        <th class="header">Title 1</th>
        <th class="header">Level 1</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Example title 1</td>
        <td>Example level 1</td>
      </tr>
      <tr>
        <td>Example title 2</td>
        <td>Example level 2</td>
      </tr>
    </tbody>
  </table>      
  • 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-15T05:03:14+00:00Added an answer on May 15, 2026 at 5:03 am

    You need to call $("#myTable").trigger("update"); after the table data is inserted.

    Please take a look at this example on the tablesorter website, it may help you clean up your code for the loading of the content as well.

    If you need more help / code, just post a comment. (I think it’ll be better for you to figure it out instead of spoon-feeding that’s why I’m not including it here.)

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

Sidebar

Related Questions

I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have a link, that when I click it calls a javascript function with
I have a page with a menu that uses JQuery AJAX calls to populate
I have a website that uses ajax jquery and facebox. Demo here : http://temp.nevergone.eu/facebox.php
I have created jquery-ajax call for php page that creates content by selecting data
I have an AJAX link that currently loads a partial view into a div.
I have a function in jQuery and I want that where that function is
I have a link that looks like <a class=fancy href=/site/feedback>feedback</a> Ajax call: $('.fancy').fancybox({ wrapCSS:
I have a site that is Ajaxed, content that is Ajax is from other
I have several links that points to a single AJAX url. I can load

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.