用Javascript请求Json

sam*_*_33 5 javascript json response

我只是java脚本和JSON的初学者,从来没有在这些方面做过任何工作.我的雇主刚刚要我创建这些的基本POC.
场景: 我有一个REST API,当我调用它时,它以JSON格式返回响应.
需要: 创建一个HTML页面并使用javascript调用该REST API并捕获JSON响应并在同一HTML页面中打印.

<script type="text/javascript">
    function loadMe() {
       loadJSON('http://myrestAPI');
   }
        function loadJSON(url) {
            //Help me here to capture the response and print in html page. 
         }
</script>
Run Code Online (Sandbox Code Playgroud)

我很感激你的帮助.这可能很简单,但对我来说我不知道​​,因为我从来没有在java脚本和json中做过类似的事情.我护目镜但找不到任何东西.

谢谢,chota

Pra*_*eth 0

$.getJSON(url, null, function (data) { .... });
Run Code Online (Sandbox Code Playgroud)