1

I am getting some text from a php file by using ajax like so:

var oReq = new XMLHttpRequest(); //New request object
  oReq.onload = function() {

      console.log(this.responseText); 
      $('#twitterFeed').append(this.responseText);
  };
  oReq.open("get", "library/twitter.php", true);
  //                               
  oReq.send();

And it works just fine, adding the text to a div set up in the HTML file. The issue is I am using jticker to scroll the text but when I load the text via AJAX it wont scroll. If I paste the text in the div manually it will. I suspect since the text is being loaded in, the jticker.js is not appending the necessary classes to the div to make it scroll.

3
  • 1
    You probably need to call jTicker on the element every time the contents change because it probably re-measures the element when you call $('.ticker').jTicker(); Commented Apr 28, 2015 at 23:29
  • Thanks! I just put the $('.ticker').jTicker(); within my AJAX callback function and it seems to be working now. Commented Apr 28, 2015 at 23:33
  • Thanks, just moved it now. Commented Apr 28, 2015 at 23:50

1 Answer 1

1

You need to call jTicker on the element every time the contents change because it probably re-measures the element when you call $('.ticker').jTicker();

Example:

var oReq = new XMLHttpRequest(); //New request object
oReq.onload = function() {

    console.log(this.responseText); 
    $('#twitterFeed').append(this.responseText);

    // ADD THIS:
    $('.ticker').jTicker();

};
oReq.open("get", "library/twitter.php", true);
//                               
oReq.send();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.