ajax 调用
一、Post
$("#btn30").on('click', function () { $.ajax({ type: "post", contentType: "application/json", dataType: "json", url: "https://localhost/api/app/abc", data: JSON.stringify({ "server": "ddd", "address": "aaa@bbb.ccc", "displayName": "aaa" }), success: function (result) { console.log(result); alert("SUCCESS:" + JSON.stringify(result)); }, error: function (msg) { console.log(msg); alert("ERROR:" + JSON.stringify(msg)); } }); });
二、Put
$("#btn28").on('click', function () { $.ajax({ type: "put", contentType: "application/json", dataType: "json", url: "https://localhost/api/app/ddd/e5a4e4a7-e4ea-45a0-b2ce-5eaee475736d", data: JSON.stringify({ url: "https://www.baidu.com" }), success: function (result) { console.log(result); alert("SUCCESS:" + JSON.stringify(result)); }, error: function (msg) { console.log(msg); alert("ERROR:" + JSON.stringify(msg)); } }); });
三、Delete
$("#btn29").on('click', function () { $.ajax({ type: "delete", contentType: "application/json", dataType: "json", url: "https://localhost/api/app/nnn/e5a4e4a7-e4ea-45a0-b2ce-5eaee475736d", success: function (result) { console.log(result); alert("SUCCESS:" + JSON.stringify(result)); }, error: function (msg) { console.log(msg); alert("ERROR:" + JSON.stringify(msg)); } }); });
四、Get
$("#btn24").on('click', function () { $.ajax({ type: "get", headers: { "Authorization":"Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjNCMkYxRjRFRUU4MjNDODlCMUU1N0UyNEMzRUJFNzVBRjBGMEM4MEEiLCJ4NXQiOiJPeThmVHU2Q1BJbXg1WDRrdy12bld2RHd5QW8iLCJ0eXAiOiJhdCtqd3QifQ.eyJpc3MiOiJodHRwczovL2xvY2FsaG9zdDo0NDMzOC8iLCJleHAiOjE3Mjk3MzU2NDQsImlhdCI6MTcyOTczMjA0NCwiYXVkIjoiSXNwV2ViIiwic2NvcGUiOiJJc3BXZWIiLCJqdGkiOiJkMGRhYzc2YS1jOGMxLTRhOTAtYWU3Yy1jNTMwZDFiZTAxNWMiLCJzdWIiOiIzYTE1Y2IwNy00NmNkLTEyYWEtM2Q4OC1mOGVmMDYxM2U1N2QiLCJ1bmlxdWVfbmFtZSI6ImFkbWluIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4iLCJnaXZlbl9uYW1lIjoiYWRtaW4iLCJyb2xlIjoiYWRtaW4iLCJlbWFpbCI6ImFkbWluQGFicC5pbyIsImVtYWlsX3ZlcmlmaWVkIjoiRmFsc2UiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOiJGYWxzZSIsIm9pX3Byc3QiOiJJc3BXZWJfQXBwIiwiY2xpZW50X2lkIjoiSXNwV2ViX0FwcCIsIm9pX3Rrbl9pZCI6IjNhMTVjZTNkLTNkY2MtNjQ3Yy1kYjFhLTQ1ODc2MGQwMjA0NiJ9.RrtxIQvXavfz8k9UlSrkDbbIvGztHXan6FfBkXv4efNsnJJAnf8_wwUaCbQiC6u2YNhkW2TZ-TnpYZ2V8dF2OmzKk-FsYxVPt822sXhVac4yOysUKBngRb8l1FV7ybswIEY6NjXwUt3UD2uCd0smP_AiTkWxITVg-gXnpbS_onXTrkMGJxcBoxLCKlGBX6nH7uxzClyiOZDndOotIDhwNWJTNcf_IrLu4Ey3zBHi8mACx-m_J7XgWRgjMwD24auJC3O62jNlY1ZsHLRuzxQFvj9OFaQjBqGrk-BPQCKonfrgHMBzPnWhD1yxJ1qZ154nxbxNJMK1smPb-m0iJCmc7w" }, contentType: "application/json", url: "https://localhost:44338/api/app/mmm?DomainName=www.shhh.com&sorting=name desc", success: function (result) { console.log(result); }, error: function (msg) { alert("ERROR" + JSON.stringify(msg)); } }); });