javascript - JS function not sending a request -


this code should work i'm missing something, how can debug js code know where's problem? i'm sending user input (string) third party api, should expect json results in <p class="score"> nothing happens!

var myurl = 'https://apiv2.indico.io/sentiment'; var api_key = 'xxxxxxxxxxxxxxxxxxxxxxx';   function apirequest() {      var mydata = document.getelementbyid('userinput').value;      $.post(       myurl,         json.stringify({         'api_key': api_key,         'data': mydata,        }).then(function(sent) {           var s = sent         var obj = json.parse(s)          $('.score').append(obj.results)   }); 

html

<input placeholder="i love writing code!" id="userinput">      <button onclick="apirequest" id="submit">try it</button>  <p class="score">score : </p> 

the userinput not passed javascript it's accessible via alert


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -