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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -