Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created February 3, 2012 15:29
Show Gist options
  • Save bennadel/1730749 to your computer and use it in GitHub Desktop.
Save bennadel/1730749 to your computer and use it in GitHub Desktop.
ColdFusion Supports HTTP Verbs PUT And DELETE (As Well As GET And POST)
<!---
Create a buffer for our output of the way various Scopes are
presented during different HTTP requests.
--->
<cfsavecontent variable="debugOutput">
<cfdump
var="#cgi#"
label="CGI Scope"
show="content_type, request_method"
/>
<br />
<cfdump
var="#getHttpRequestData()#"
label="HTTP Request Data"
/>
<br />
<cfdump
var="Content: #toString( getHttpRequestData().content )#"
label="Content"
/>
<br />
<br />
<cfdump
var="#url#"
label="URL Scope"
/>
<br />
<cfdump
var="#form#"
label="Form Scope"
/>
</cfsavecontent>
<!--- Send HTML output back to the client. --->
<cfcontent
type="text/html; charset=utf-8"
variable="#toBinary( toBase64( debugOutput ) )#"
/>
<!DOCTYPE html>
<html>
<head>
<title>Checking ColdFusion's Support For PUT And DELETE</title>
</head>
<body>
<h1>
Checking ColdFusion's Support For PUT And DELETE
</h1>
<h2>
PUT Response
</h2>
<div id="putResponse">
<!-- To be populated dynamically. -->
</div>
<h2>
DELETE Response
</h2>
<div id="deleteResponse">
<!-- To be populated dynamically. -->
</div>
<script type="text/javascript" src="../jquery-1.7.1.js"></script>
<script type="text/javascript">
// Make PUT request.
$.ajax({
type: "PUT",
url: "./api.cfm?dataValue1=Sent+in+URL",
data: {
dataValue2: "Sent in Data."
},
dataType: "html",
success: function( content ){
// Inject PUT output.
$( "#putResponse" ).html( content );
}
});
// Make DELETE request.
$.ajax({
type: "DELETE",
url: "./api.cfm?dataValue1=Sent+in+URL",
data: {
dataValue2: "Sent in Data."
},
dataType: "html",
success: function( content ){
// Inject DELETE output.
$( "#deleteResponse" ).html( content );
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Checking ColdFusion's Support For PUT And DELETE</title>
</head>
<body>
<h1>
Checking ColdFusion's Support For PUT And DELETE
</h1>
<h2>
PUT Response (Using JSON.stringify)
</h2>
<div id="putResponse">
<!-- To be populated dynamically. -->
</div>
<h2>
DELETE Response (Using JSON.stringify)
</h2>
<div id="deleteResponse">
<!-- To be populated dynamically. -->
</div>
<script type="text/javascript" src="../jquery-1.7.1.js"></script>
<script type="text/javascript">
// Make PUT request.
$.ajax({
type: "PUT",
url: "./api.cfm?dataValue1=Sent+in+URL",
contentType: "application/json",
data: JSON.stringify({
dataValue2: "Sent in Data."
}),
dataType: "html",
success: function( content ){
// Inject PUT output.
$( "#putResponse" ).html( content );
}
});
// Make DELETE request.
$.ajax({
type: "DELETE",
url: "./api.cfm?dataValue1=Sent+in+URL",
contentType: "application/json",
data: JSON.stringify({
dataValue2: "Sent in Data."
}),
dataType: "html",
success: function( content ){
// Inject DELETE output.
$( "#deleteResponse" ).html( content );
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment