Xiang Wang @ 2019-06-18 09:59:59
<script src="https://code.jquery.com/jquery-3.7.0.min.js" type="text/javascript"></script>
- jQuery.ajax
$.ajax({ url:"/upload/file/", type: "POST", async: true, # 普通请求 data: { data:reader2.result, }, # json请求 contentType: "application/json; charset=utf-8", data: JSON.stringify(data), beforeSend: function(request) { request.setRequestHeader("Test", "Chenxizhang"); }, success:function(responseTxt){ console.log('ok'); }, error: function(jqXHR, textStatus, errorThrown){ console.log("错误") console.log(jqXHR.responseJSON) }, });
- 发送json请求
$.ajax({
data: Object,
dateType: "json",
success: function(res) {
res直接就是数据了
}
})
- jQuery.get
jQuery.get( url [, data ] [, success ] [, dataType ] )
- jQuery.getJSON
$.getJSON("/text/", {}, Function( PlainObject data, String textStatus, jqXHR jqXHR )).fail(function(res) { toastr.error(res.responseText); })
- jQuery.post
jQuery.post( url [, data ] [, success ] [, dataType ] )
- toggle:
$('#id').toggle()