I am developing a site on WordPress that uses the JavaScript-based plotting library, Plotly, to plot data retrieved from a data server. I need the user to be able to enter text into a text field that will update the graph as the user types. I want the site to work similar to this w3schools example.

What I have so far:

  • I can run JavaScript in my page using this plugin, Scripts and Styles.
  • I can run the Ploty graph on the page using the Scripts and Styles plugin using this code:

    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    <div id="tester" style="width:600px;height:250px;"></div>
        TESTER = document.getElementById('tester');
        Plotly.plot( TESTER, [{
            x: [1, 2, 3, 4, 5],
            y: [1, 2, 4, 8, 16] }], {
       margin: { t: 0 } } );

What I'm missing:

  • I don't know how to make JavaScript send an AJAX to a custom PHP plugin to retrieve data to post back to the Plotly graph.

Moral of the story, I need to be able to update a Plotly graph on a WordPress site.

Thanks in advance!

1 Answer 1


There's a lot of good resources out there to help you build a plugin, but the one I recommend most is the WordPress Plugin Developer Handbook, especially the section on Ajax. You will still need to figure out the functionality needed for the Plotly data, but that should get you in the right direction.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.