Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

a tag how to trigger ajax

document.querySelector("#myId").onclick = function(e) {
  e.preventDefault();
  
  $.ajax({
    url: 'api_url',
    type: 'post',
    data: {key: 'value'},
  })
  .done(function() {
    console.log("success");
  })
  .fail(function() {
    console.log("error");
  });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #tag #trigger #ajax
ADD COMMENT
Topic
Name
2+2 =