我想輸入一些東西到輸入字段中,然後從API獲取響應(如果值存在與否)。使用jQuery獲取API的響應
如果郵政編碼(12345)存在,API將以真/假值進行響應。 http://192.168.100.100:8887/public?zipcode=12345
而且這裏是我到目前爲止的代碼:
$(function() {
$('.positiveMessage, .negativeMessage').hide()
$('#submitBtn').on('click', function() {
var $zipcode = document.getElementById('searchZipCode').value
$.getJSON({
type: 'GET',
url: 'http://192.168.100.100:8887/public?zipcode=' + $zipCode,
success: result => {
//Goes through the array
$.each(result, function(i, info) {
$('body').append(info + '')
})
}
})
})
})
正如你看到的,我想通過在鏈接中加入一個變量來操縱API。
你給一個本地IP;) –
行動!我會寫出JSON! –
你正在循環布爾? –