I am trying to build an embeddable widget, with WordPress as the server. I have products and I have created my WP API endpoints where I can curl them and get my JSON back.

I have an existing structure from our old system I am piggybacking on for now until phase two, so there is an embedded script already that will be one of my endpoints.

When that gets pinged, I am verifying privileges etc, but need to “return” a loader/utility script to pop into the head of the site calling it so that it can handle the rest of the API calls etc.

I cannot for the life of me figure out that part though, how to get that script to return and be added to the DOM instead of returning JSON like normal.

I hope this makes sense, any input?

Thank you.

Read more here: How can I return a JavScript file from a PHP API call?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: