Skip to content

Instantly share code, notes, and snippets.

@nmvuong92
Last active March 22, 2019 04:33
Show Gist options
  • Save nmvuong92/3bbad6748190583111f93909b1d2a1d0 to your computer and use it in GitHub Desktop.
Save nmvuong92/3bbad6748190583111f93909b1d2a1d0 to your computer and use it in GitHub Desktop.
jquery-ajax-standard.js
//tham request số gọi ajax
var _param = {
pid:1,
color:'red'
};
//gọi ajax
$.ajax({
url:'https://jsonplaceholder.typicode.com/posts', //lấy danh sách bài viết
method:'get', //phương thức post/get
dataType:'json', //kiểu json
data: _param, tham request số gọi ajax
beforeSend:function(){
//$('#ajax_loading_box').show();
},
success:function(data){
//nhận được dữ liệu khi gọi ajax thành công
console.log(data);
},
complete:function(){
//$('#ajax_loading_box').hide();
},
error: function(xhr) {
//xhr.statusText
//xhr.responseText
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment