Last active
July 14, 2016 16:42
-
-
Save junxie6/3ef77f0959c36fa58b841c8c60e1aac7 to your computer and use it in GitHub Desktop.
ajax sample
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
<html> | |
<head> | |
<script src="/static/jqwidgets-ver4.1.2/scripts/jquery-2.2.4.min.js"></script> | |
<script> | |
$( document ).ready(function() { | |
var token = ""; | |
// Global AJAX Configuration | |
$.ajaxSetup({ | |
type: 'post', | |
contentType: 'application/json; charset=utf-8', | |
dataType: 'json', | |
timeout: 60 * 1000, | |
headers: { | |
Authorization: token, | |
}, | |
//xhr: myLib.openAjaxLoader(), | |
}); | |
$('.clickMe').on('click', function(event){ | |
event.preventDefault(); | |
var act = $(this).attr('data-act'); | |
var optObj = {}; | |
optObj.IsConfirm = true; | |
$.ajax({url: '/SalOrder?act=' + act, data: JSON.stringify(optObj) | |
}).done(function(dataObj){ | |
console.log(dataObj); | |
}).fail(function(dataObj){ | |
console.log(dataObj); | |
}).always(function(dataObj) { | |
//console.log(dataObj); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<p class="clickMe" style="cursor: pointer;" data-act="Save">Save</p> | |
<p class="clickMe" style="cursor: pointer;" data-act="Test">Test</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment