a tag how to trigger ajax

Solutions on MaxInterview for a tag how to trigger ajax by the best coders in the world

showing results for - "a tag how to trigger ajax"
Josué
05 Oct 2017
1document.querySelector("#myId").onclick = function(e) {
2  e.preventDefault();
3  
4  $.ajax({
5    url: 'api_url',
6    type: 'post',
7    data: {key: 'value'},
8  })
9  .done(function() {
10    console.log("success");
11  })
12  .fail(function() {
13    console.log("error");
14  });
15}