Skip to content

Instantly share code, notes, and snippets.

@junxie6
Last active July 14, 2016 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junxie6/3ef77f0959c36fa58b841c8c60e1aac7 to your computer and use it in GitHub Desktop.
Save junxie6/3ef77f0959c36fa58b841c8c60e1aac7 to your computer and use it in GitHub Desktop.
ajax sample
<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