I'm trying to get a form posted to a remote server. The general idea, for now, is that the HTML will run locally and will post to a remote server via AJAX.
So there's a form, the JS and the CFC it's posting to.
Below is the 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, //CFARGUMENT: JS_VARIABLE
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 that it is being posted to (I've cut out a lot of it 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: Cleaned up CFC, removed extraneous comments.
Doing research, I've come across that CFHEADER was supposed to go on top, to allow cross origin, however, Chrome still presents a No 'Access-Control-Allow-Origin' header is present on the requested resource. error.
A couple background things: I'm on a shared host. I have a blank Application.CFC in the folder that the CFC resides in.
setEntry, which is the name of the function? - Chester