0

I have a php file that echos JSON encoded arrays, the contents of which are pulled from a remote database.

I want to be able to pass this data from the PHP file to a Javascript file linked to a running HTML file displayed in the browser.

What are the best practises for passing data, particularly in JSON format fromPHP to Javascript...

3
  • Look up this popular thing called "Ajax". Commented Aug 7, 2011 at 2:30
  • Can you clarify? Is the PHP script with the arrays generating the HTML file, which has the reference to the JS script? Or is the JS script querying a separate PHP script? Commented Aug 7, 2011 at 2:32
  • the latter. the html file will trigger a js function that queries the php Commented Aug 7, 2011 at 2:40

1 Answer 1

1

The jQuery Javascript library provides a bunch of great ways for handling Ajax. JSON is a wonderful format for client/server communication, even as-is. XML is also good.

If you are talking about long polling, you may also want to look into COMET

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

Comments

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.