Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajaxTest() {
- var obj = {};
- obj.name = "check this outa";
- alert(obj+"");
- var token = $("meta[name='_csrf']").attr("content");
- var header = $("meta[name='_csrf_header']").attr("content");
- $.ajax({
- beforeSend: function(xhr) {
- xhr.setRequestHeader("Accept", "application/json");
- xhr.setRequestHeader("Content-Type", "application/json");
- xhr.setRequestHeader(header, token); },
- // url: 'http://localhost:8080/Restaurant/rest3/',
- url: 'http://localhost:8080/Restaurant/test/rest/ingredient/add',
- data: JSON.stringify(obj),
- type: "POST",
- dataType: "json",
- processData:false ,
- success: function (result) {
- switch (result) {
- case true:
- alert(result);
- break;
- default:
- alert(result);
- }
- },
- error: function (xhr, ajaxOptions, thrownError) {
- alert(xhr.status);
- alert(thrownError);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement