2016-07-13 2 views
-3

내가내가 아약스는

xhr.onreadystatechange = function (event) { 
    if (xhr.readyState === 4 /** responseText is not available yet */) { 
     const statusCode = xhr.status 
     const responseText = xhr.responseText 

     /** blah blah */ 
    } 
} 

같은 XMLHttpRequest의 사용 반환 일부 매개 변수를 처리 할하지만 난 그에 statusCode과에서 responseText를받을 수있는 방법을 지금, 나는

$.ajax({ 
    url: url, 
    data: payloads, 
    contentType: 'text/plain', 
    type: 'POST', 
    }) 

같은 Ajax를 요청입니까? 과 같은 기능을 어떻게 처리 할 수 ​​있습니다. .done 또는 .success 함수를 추가한다고 들었는데, 하지만 어떻게 다른지 모르겠습니다.

나는 당신의 친절 기다리고

+0

검색을 시도 할 수 있습니다? http://hayageek.com/jquery-ajax-post/ –

+0

검색하셨습니까? POST를 사용하고 GET을 사용하지 않아도됩니까? – Roysh

+0

하지만 responseText 및 statusCode를 수신 할 방법이 없습니다. – pebC

답변

0

당신이

$.ajax({ 
    url: url, 
    data: payloads, 
    contentType: 'text/plain', 
    type: 'POST', 
    }).done(function(data) { //fetches the data after AJAX call 
     const statusCode = data.status; 
     const responseText = data.responseText; 
    }); 
+0

나는 이것을 시험해 볼 것이다. 행운을 빕니다 – pebC