javascript - How can I embed a simple, type JSON, web service into my website using JS -


i having trouble trying work out how embed simple web service website. url of web service example.com/movie-trivia.php. displays randomly generated json type string such as:

{"movie-trivia":"for american release, first 20 minutes of  trainspotting had re-dubbed make scottish accents more intelligible."} 

i need embed on 1 of web pages every time page refreshed, 1 of many randomly generated movie trivia's source displayed. add, every time source url page refreshed displays 1 random trivia every time, wish do.

i new web development technologies if kind , provide me solution of how directly implement 1 of pages.

i solved question using php solution.

<?php  # http request  $url = 'http://www.example.com/movie-trivia.php'; $ch = curl_init($url); curl_setopt($ch, curlopt_timeout, 5); curl_setopt($ch, curlopt_connecttimeout, 5); curl_setopt($ch, curlopt_returntransfer, true); $data = curl_exec($ch); curl_close($ch); echo $data;  ?> 

the solution displays dynamic contents of web-service. have decode json output text without key/value structure.

thanks helping guys.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -