Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

What is the best way to get data from a #sql-server, when i want to process it on the client side via #javascript? I have a IIS webserver with MS SQL Server database. On my website, i want to get data from the database to process it as JSON. I tried with php, but i have to store the sql-results in html first, before i can read them with javascript. since the datasets are pretty big, it does not seem like nice solution to me. What about AJAX? I don't know so much of it. Could be a better solution?

OpenStudy (anonymous):

Best solution is subjective, you could use node.js (serverside javascript) to query and expose the data to your client-side javascript, alternatively you could write a simple api server in Python that would query based on what you need at that time and return you json, PHP could do it, if the dataset is large you're going to be retrieving it large no matter what, anyway, you could invoke dynamic output so that the dataset returned is only as large as it needs to be for that particular piece of json. You could also approach it with technically like AJAX which is really just a fake socket implementation for client-side javacript to perform polling. However you would still need some technology in place to handle that request as it cannot communicate directly with MSSQL.

OpenStudy (anonymous):

typo correction: technology like AJAX**

OpenStudy (anonymous):

In the end I used the php library sql2json, which transforms my sql result in php to a json-string, which is stored in html. on the client side, i read this string from the DOM with javascript and do eval(). still i think it's a strange solution, since this should be an everyday-task, no.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!