Last active
October 8, 2015 17:40
-
-
Save danielalvarenga/171aa289b31b6a02e4e8 to your computer and use it in GitHub Desktop.
Ajax call with header params example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adicionar JQuery ao console | |
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document); | |
Chamada AJAX | |
$.ajax({ | |
headers: { | |
"Accept": "application/json; charset=utf-8", | |
"Content-Type": "application/json; charset=utf-8", | |
"Token": "123456789" | |
}, | |
type: "POST", | |
url: "http://exemplo.com.br", | |
data: "{\"order\":{\"checkout_id\":\"teste1\",\"checkout_date\":\"2015-10-02 19:34:20\",\"type_checkout\":\"online\",\"bonus\":1660,\"cep\":\"05802140\",\"state\":\"SP\",\"items_attributes\":[{\"sku\":\"GRE8951\",\"bonus\":1660}]}}", | |
dataType: "json", | |
crossDomain: true, | |
success: function(data, textStatus, xhr){ | |
console.log(xhr.status + " - " + JSON.stringify(data)); | |
}, | |
error: function(data, textStatus, xhr){ | |
console.log(data.status + " - " + data.responseText); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment