vendredi 20 octobre 2017

Random Word API Usage

I'm trying to use the random word api from setsetgo.

So I build this html to test it out

<!DOCTYPE html>
<html>
<body>

<script>
    function RandomWord() {
        var requestStr = "http://ift.tt/1ivdniZ";

        $.ajax({
            type: "GET",
            url: requestStr,
            dataType: "jsonp",
            jsonpCallback: 'RandomWordComplete'
        });

    }


    function RandomWordComplete(data) {
        alert(data.Word);
    }

    RandomWord();
    RandomWordComplete(data);
</script> 

</body>
</html>

It seems like the script stop when I do $.ajax() . Though, I don't know what I'm doing wrong.

Aucun commentaire:

Enregistrer un commentaire