I am trying to load products number with AJAX. The code will be more complicated but to simplify the question, there is a block on the /category-one/
<div id="products-count">6</div>
Let's say, I am on any other page, home for example. I am trying to get that "6". I have tried the following but the alert is empty.
var url = '/category-one/';
$.ajax({
url: url,
success: function(data) {
var $fullContent = $('#products-count', data)
var text = $fullContent.text();
alert(text);
}
});
What is wrong with this code? Thank you for your help in advance.