I am trying to get a form submitted to a remote server. At this point, the general idea is that HTML will execute locally and will be sent to the remote server via AJAX.
So, there is a form, JS and CFC that it submits.
Below is JS
$(document).ready(function () {
$("#submit").click(function(){
var setName = $("input[name='setName']").val();
var setNumber = $("input[name='setNumber']").val();
var setTheme = $("input[name='setTheme']").val();
var retailPrice = $("input[name='retailPrice']").val();
var purchaseStore = $("input[name='purchaseStore']").val();
var purchaseDate = $("input[name='purchaseDate']").val();
var purchasePrice = $("input[name='purchasePrice']").val();
var condition = $("input[name='condition']").val();
var sellPrice = $("input[name='sellPrice']").val();
var sellStore = $("input[name='sellStore']").val();
var selldate = $("input[name='selldate']").val();
$.ajax({
type: 'get',
url: 'http://www.chesteraustin.us/cfc/entry.cfc?ReturnFormat=json',
data: {
method: 'setEntry',
Set_Name: setName,
Set_Number: setNumber,
Set_Theme: setTheme,
Retail_Price: retailPrice,
Purchase_From: purchaseStore,
Purchase_Price: purchasePrice,
Purchase_Date: purchaseDate,
Status: condition,
Sell_Date: sellPrice,
Sell_from: sellStore,
Sell_date: selldate
},
contentType: 'json',
dataType: 'json',
success: function(response) {
console.log("you da man");
}
});
});
});
Below is the CFC on which it is sent (I have abbreviated it a lot for brevity):
<cfcomponent>
<cfheader name="Access-Control-Allow-Origin" value="*" />
<cfheader name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE" />
<cfheader name="Access-Control-Allow-Headers" value="Content-Type" />
<cffunction name="setEntry" access="remote">
<cfreturn 1>
</cffunction>
</cfcomponent>
EDIT: clear CFC, remove extraneous comments.
While doing research, I came across the fact that I CFHEADERhad to go from above to allow cross origin, however Chrome still presents an error No 'Access-Control-Allow-Origin' header is present on the requested resource..
A few minor things: I'm on a shared host. I have an empty Application.CFC in the folder where the CFC is located.