У меня есть JS Fiddle, поиск не работает.Я думаю, что это из-за устаревания, но я видел и читал документацию для текущей версии 3.1, и она не работает после того, как я внес изменения
Я пытался гуглить и искать видео по всемуyoutube по учебным пособиям для версии 3.1 и попытался изменить код здесь и там.
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<div id="searchcontainer">
<div id="search">
<input placeholder="enter name"></input>
<div id="source">Powered by Crunchbase</div>
</div>
</div>
<div id="form">
<div id="desc"></div>
<div id="results"></div>
<div id="total"></div>
<div id="acquired"></div>
<div id="comp"></div>
</div>
var key = '854yf2awd662y74jfqd6kru5';
var company = '';
$('input').keypress(function (e) {
if (e.which == 13) {
clearFields();
getDetails($(this).val());
}
});
function clearFields() {
$('#desc').html('');
$('#results').html('');
$('#total').html('');
$('#acquired').html('');
$('#comp').html('');
$('#desc').html('<div style="width: 100%; text-align: center;"><img src="https://shop.septa.org/skins/SEPTA/customer/images/snake_transparent.gif"/><br/>Loading</div>');
};
function getDetails(co) {
company = co;
var url = "https://api.crunchbase.com/v3.1/organizations?user_key=854yf2awd662y74jfqd6kru5"
$.getJSON(url, function (data) {
var output = '<h3>Funding Rounds</h3>';
var competition = '<h3>Competitors</h3><ul>';
var total_raised = 0;
console.log(data);
for (var i in data.funding_rounds) {
output += '<ul id="dates"><li>';
output += dateFormat(data.funding_rounds[i].funded_month, data.funding_rounds[i].funded_day,data.funding_rounds[i].funded_year);
output += '</li></ul><ul id="amounts"><li>';
output += numberWithCommas(data.funding_rounds[i].raised_amount);
output += '</li></ul>';
total_raised += data.funding_rounds[i].raised_amount;
}
$('#desc').html('<h3>'+ data.description + '</h3><h4>'+data.overview+'</h4><h5>' + data.homepage_url + '</h5><h5>est. ' + dateFormat(null, null, data.founded_year) + '</h5>');
$('#results').html(output);
$('#total').html(numberWithCommas(total_raised));
if(data.acquisition == null) {
if(data.deadpooled_year == null) {
if(data.ipo == null) {
$('#acquired').html('<span style="color: rgba(0,120,255,1)">Alive and kickin\'</span>');
} else {
$('#acquired').html(data.ipo.stock_symbol + '<br/>' + dateFormat(null, null, data.ipo.pub_year) + '<br/>' + numberWithCommas(data.ipo.valuation_amount));
}
} else {
$('#acquired').html('<span style="color: red">Deadpool</span>');
}
} else {
$('#acquired').html('Acquired by ' + data.acquisition.acquiring_company.name + '<br/>' + numberWithCommas(data.acquisition.price_amount));
}
for (var j in data.competitions) {
competition += '<li>'+data.competitions[j].competitor.name+'</li>';
}
competition += '</ul>';
$('#comp').html(competition);
styles();
})
.fail(function(){
$('#desc').html('No Results Found');
});
};
function numberWithCommas(x) {
if(x == null) {
return '';
} else {
return '$' + x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
function dateFormat(m,d,y) {
if(d == null) {
if(m == null) {
if(y == null) {
return '';
} else {
return y;
}
} else {
if(y == null) {
return '';
} else {
return m + '/' + y;
}
}
} else {
if(m == null) {
return '';
} else {
if(y == null) {
return m + '/' + d;
} else {
return m + '/' + d + '/' + y;
}
}
}
}
function styles() {
$('#comp li').click(function() {
clearFields();
$('input').val($(this).html());
getDetails($(this).html().toLowerCase());
});
var h4Height = $('#desc h4').height();
$('#desc h4').css({
'height': '130px'
});
$('#desc h4')
.mouseenter(function(){
$(this).css('height', Math.min(Math.max(h4Height+10,130),400) + 'px');
$('body').css('overflow','hidden');
$('body').animate({
'scrollTop': 0
}, 500);
})
.mouseleave(function(){
$(this).css('height','130px');
$('body').css('overflow','auto');
$(this).animate({
'scrollTop': 0
},500);
});
$(window).scroll(function() {
if($(this).scrollTop() > 10) {
$('#searchcontainer').css({
'box-shadow': '2px 0px 10px 3px rgba(0,0,0,0.1)'
});
$('input').css({'border-bottom':'0px'});
} else {
$('#searchcontainer').css({
'box-shadow': '2px 0px 10px 3px rgba(0,0,0,0)'
});
$('input').css({'border-bottom':'1px solid #ccc'});
}
});
}
Фактический результат - результаты поиска не отображаются при отправке запроса.
Ожидаемый результат -результаты поиска отображаются при нажатии enter
Вот JS FIDDLE, с которым я работаю. Любая помощь приветствуется!Спасибо !!
http://jsfiddle.net/myh2002/f8Pn4/12/