1

I am aggregating data through different sources and compiling them into a mongoDB database on my computer.

My goal is to then have a wordpress website that then serves up some of that data to visitors through javascript code/dashboards. The MongoDB database will also be continually updated (a few times a week).

Would it be feasible/simple to connect the mongoDB database to the wordpress site, or is there a better way to structure this?

1 Answer 1

1

JavaScript, client side, does not directly access a server's database. You would need to use an API of some sort to call the PHP Wordpress script and refresh the page that way. Or, if it only updates a few times a week, just use the JavaScript to notify the user when to refresh the page. PHP should have no problem displaying DB results

Sign up to request clarification or add additional context in comments.

8 Comments

"PHP should have no problem displaying DB results" - so if I want to have javascript render some of the DB results, I should get the results and pass custom Javascript to the page via PHP?
What are you trying to do? Do you want the page to display data without a refresh?
Ideally, no, I would want to have the data displayed be refreshed, daily if at all possible. I'm just still unsure as to how to get the javascript to display certain contents of the database, in a dashboard, if you will.
You can, you can use PHP to send data to the page in the <header> element or directly inject data into a script, and then display it using your javascript.
@OSK The problem with directly accessing the Database using Javascript, is that is a major security flaw. Javascript is client side, everyone can see the code that is there. If you use PHP to just get the data, and print it to the page somewhere hidden from view, you can just use Javascript to display it.
|

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.