0
jquery ajax에 대한 자습서를 따르고 있습니다. GET 요청을 실행하면 내 로컬 호스트에서 값이 정의되지 않은 상태로 표시됩니다. jquery ajax GET 요청이 정의되지 않은 값으로 돌아옵니다.
이
는 HTML 코드 여기<div>
<h1>jQuery Ajax</h1>
<h2>Friends</h2>
<ul id="friends">
</ul>
<h4>Add a Friend</h4>
<p>name: <input type="text" id="name"></p>
<p>drink: <input type="text" id="drink"></p>
<button id="add-order" class="btn btn-primary">Add!</button>
</div> <!--end of container-->
내 jQuery 코드입니다 :
http://rest.learncode.academy/
: 여기
var $friends = $('#friends');
$.ajax({
type: 'GET',
url: 'http://rest.learncode.academy/api/johnbob/friends',
success: function(){
$.each(friends, function(i, friend){
$friends.append('<li>name: '+friend.name+' , age: '+friend.age+' </li>');
})
}
});
내가 정보를 요청하기 위해 노력하고있어 REST API에 링크의
here이 성공 기능 등으로 데이터를 전달 참조하십시오. "성공 : function (friends) {..." –