基本结构:
$.ajax({ url: 请求的url, type: 请求方式(get/post/put/....), data: 响应数据(通常会使用json.stringfy()进行操作), //dataType: ‘jsonp‘, //注意,如果跨域才添加 beforeSend: function () { // 执行一些请求开始前的操作,比如:防止用户重复点击,数据加密 }, success: function (res) { // 成功响应消息体 }, error: function (xmlHttpRequest, textStatus, errorThrown) { alert(xmlHttpRequest.responseText); // 输出返回的响应信息 } });
原文:https://www.cnblogs.com/namejr/p/11653747.html