We help IT Professionals succeed at work.
Get Started

Jquery won't fire after postback

sherbug1015 asked
Last Modified: 2015-08-27
I have a jquery where we are trying to track what documents our users are viewing in our Document Library.  Users can upload a document and there is a pagination widget as well.

This is the jquery

$(document).ready(function(){  //
  $(".FileCabinet a").click(function () {
                    //$(document).on("click", "a", function() {
  if (! $(this).attr("href") ) {
  else {  
      var href = $(this).attr("href");
      var mystring = href.replace(/.*\?/,'');  //remove everything before the ?
      var mystring1 = mystring.replace(/\&.*/,''); //remove the hash key
      var mystring2 = mystring1.replace(/[^\d\.]/g, ''); // remove non-numerics
    type: "POST",
    url: "/CMSPages/WebService.asmx/WhoClicked",
    data: JSON.stringify({ DocumentID: mystring2}),
    contentType: "application/json",
    success: function (data) {
      // Do something on sucess
    error: function(jqXHR, status, errorThrown) {
      // Do something on failure
Whenever there is a partial postback, the jquery does not fire anymore.  I am assuming it has something to do with the document ready function.  Is there a workaround for this.  In other words how do I make this script fire on each time a document link is clicked.
Watch Question
Most Valuable Expert 2017
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE