demo:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>ajax text</title> <script type="text/javascript" src="jquery-1.12.4.min.js"></script> <script type="text/javascript"> $.ajax({ url:'https://sug.so.360.cn/suggest?', type:'get', dataType:'jsonp', data:{word:'101'} }) .done(function (data) { alert(data.s.length); for(var i=0;i<data.s.length;i++){ var $li = $('<li>'+ data.s[i] + '<li>'); $li.prependTo('.list'); } }) .fail(function () { console.log("error"); }) </script> </head> <body> <ul class="list"></ul> </body> </html>
结果显示在页面上: