Already read the documentation, applied your solution but it does not change the error.
<script>
var priceDoll = document.getElementById('priceDoll');
priceDoll.onkeyup = function(){
var e = document.getElementById("coin");
var strCoin = e.options[e.selectedIndex].text;
var coin_value;
/* Replace ./data.json with your JSON feed */
fetch('https://api.coinmarketcap.com/v1/ticker/' + strCoin + '/?convert=USD').then(response => {
return response.json();
}).then(data => {
for (var i = 0; i < data.length; i++) {
var coin_value = data[i].price_usd;
document.getElementById('coinPriceLabel').innerHTML = priceDoll.value/coin_value;
coin_value = priceDoll.value/coin_value;
/* var xhttp = new XMLHttpRequest();
xhttp.open("POST", "coin_post1.asp", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(coin_value);
*/
var request = $.ajax({
type: "POST",
url: "uploadItemInfo.php",
data: {coin_value},
//dataType: "html"
});
request.done(function(msg) {
alert ( "Response: " + msg );
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
}).catch(err => {
// Do something for an error here
document.getElementById('coinPriceLabel').innerHTML = "Sorry, can't fetch data from server";
});
}
//Changes value when selectbox is changed
function cryptoPrice(){
var priceDoll2 = document.getElementById('priceDoll');
var e = document.getElementById("coin");
var strCoin = e.options[e.selectedIndex].text;
var coin_value;
// Replace ./data.json with your JSON feed
fetch('https://api.coinmarketcap.com/v1/ticker/' + strCoin + '/?convert=USD').then(response => {
return response.json();
}).then(data2 => {
for (var i = 0; i < data2.length; i++) {
var coin_value2 = data2[i].price_usd;
document.getElementById('coinPriceLabel').innerHTML = priceDoll2.value/coin_value2;
coin_value = priceDoll.value/coin_value;
var request = $.ajax({
type: "POST",
url: "uploadItemInfo.php",
data: {coin_value},
//dataType: "html"
});
request.done(function(msg) {
alert ( "Response: " + msg );
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
}).catch(err => {
// Do something for an error here
document.getElementById('coinPriceLabel').innerHTML = "Sorry, can't fetch data from server";
});
}
</script>
<script src="ASLibrary/js/js-bootstrap.php"></script>
Hey,
You need to include js-bootstrap.php script before your custom code, not after it.
So, just make sure that it is included the js-bootstrap.php after the jQuery and but before your custom code and it should work without any issues. :)