Loading data through Rest API and DOM

Hello there!

I have a question about loading the data.

Let’s assume we have a widget. Widget outputs data with rendered HTML from a PHP callback function. (it’s okay)

The functions looks like this:

This widget also have a button that refreshes the content via Rest API request and this Rest API endpoint outputs a json data like this:

As you can guess, I need to render this data in frontend via javascript in where I made this Rest API request and insert to the DOM like this:

The question here: I have the same HTML layout in 2 files.

1 → in the PHP function that comes with the DOM from. (widget’s callback function)
2 → in the JS file that user make a Rest API request and get a json response.

Is this a problem to themeforest’s theme rules? I know I can output a rendered HTML data by using the same function that I outputs widget; but I wanna keep every AJAX/Rest API requests as JSON data.