skip to Main Content

This part of my code isn’t working, I already tried to do everything but it still doesn’t working, what can I do to fix it?

$.ajax({
    url: "https://corona-api.com/countries/BR",
    type: "GET",
    sucess: function(response){
        document.getElementById("ifbr").innerHTML = response.latest_data.confirmed
    },
    error: function(){
        document.getElementById("ifbr").innerHTML = "Erro na Consulta !"
    }
})

2

Answers


  1. I think you need to change sucess into success, and add data like below:

    $.ajax({
        url: "https://corona-api.com/countries/BR",
        type: "GET",
        success: function(response){
            document.getElementById("ifbr").innerHTML = response.data.latest_data.confirmed
        },
        error: function(){
            document.getElementById("ifbr").innerHTML = "Erro na Consulta !"
        }
    })
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <p>Confirmed: <span id="ifbr"></span></p>
    Login or Signup to reply.
  2. You have misspelled success here

    sucess: function(response)
    

    Instead it should be

    success: function(response)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search