×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Fabio Clem
Added: May 25, 2017 1:05 PM
Modified: May 25, 2017 1:16 PM
Views: 3
Tags: no tags
Ajax Simples
  1. $.ajax({
  2.     type: "POST/GET",
  3.     url: "URL",
  4.     data: DATA,
  5.     dataType: "json",
  6.     beforeSend: function (xhr) {
  7.         //Antes de enviar
  8.         xhr.setRequestHeader("Content-Type", "application/json");
  9.     },
  10.     success: function (data) {
  11.         //Sucesso do ajax
  12.         console.log(data);
  13.     },
  14.     error: function (data) {
  15.         //Erro do ajax
  16.         console.log(data);
  17.     },
  18.     complete: function () {
  19.  
  20.     }
  21. });